N
N
Nikita D2018-05-06 21:31:32
Python
Nikita D, 2018-05-06 21:31:32

Why does PyCharm highlight the variable name in red?

Problem with Pycharm: it works on startup, but if you hover over a variable name, it highlights in red. What is the problem?
5aef49d999475415321882.png

print("Тест 1")
print("Входные данные")
bic = int(input(": "))
cib = int(input(": "))
ccc = cib // bic
print(ccc)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
Fixid, 2018-05-06
@Fixid

1. You use Russian characters without declaring the encoding
Therefore, at the very beginning:

# -*- coding: utf-8 -*-
# !/usr/bin/env python

2. Press Ctrl+Alt+L to automatically format the code. The IDE is picky about missing spaces
3. There are no errors in the code. You have a warning highlighted.

X
x67, 2018-05-07
@x67

Most likely, pycharm indicates that the variable name els is very similar to the else keyword, so there could be an error here. Change the variable name to be more informative and less keyword-like. Now I don’t care, but in the future the habit of giving convenient and meaningful names will help to avoid mistakes.
Why is there a different code on the screenshot and in the question?
And just in case, remove the .py from the folder, it makes no sense and can be a source of implicit blunts or errors. *.py - extension of text python sources and nothing more. It is not necessary and not desirable to give such "extensions" to folders. And if you want to explicitly designate the YP, you can use a dash instead of a dot

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question