M
M
MYZUKA2022-01-16 02:32:20
Python
MYZUKA, 2022-01-16 02:32:20

Why doesn't the command line read the contents of the code?

61e356947b5c5277537007.png
Why does it happen that I seem to be writing valid code in sublime text (I tried different files, not only test4.py) - after which I select the desired directory in the command line or cmd (py.exe is installed by default on the C drive, and the folder python with all the codes on disk D)
after
cd D:\python
D:
python test4.py (or any other file)
the command line should give the written code but it doesn't happen, just one more time:
python
61e3591810a1a412880126.png
I just started learning python and like this here is the problem immediately stalled the process!! thank you who will answer

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Nesterov, 2022-01-16
@AlexNest

You have a clear misunderstanding of how it works print()
. Either variables or strings/numbers/data arrays (including those returned from functions\methods\etc) can be given as parameters for it. In this case, each parameter must be separated by a comma. But it is neither a variable, nor a string, nor an array of data . Besides: 1. Even sublime shows you that there is an error in the code. 2. Why don't you use ide for debugging? (I would recommend pycharm, but even the poor Python idle at 99.9% will be more useful than running through the console) \" плохой\" человек

C
che_aa, 2022-01-16
@che_aa

You go to the folder with the code, hold down the shift and right-click on an empty area in the folder, then select "Open in PowerShell window", and write in the PowerShell window "python test.py"

D
DmitryRoschupkin, 2022-01-17
@DmitryRoschupkin

I see you're learning from Howdy Ho? But not the point. I don't understand why you need backslashes there, but if you want them to be printed, then follow the nested doll principle:
print(name, '/bad/ person')
Here is the correct code if you wanted to print it along with backslashes
Why?
Because your variable is not separated by a comma, and the plus is not set, so this is the first syntax error.
The second one is \'bad\' , since it's just a syntax error.
Well, the third one. You wrote 'man' without quotes. The interpreter does not approve of this, since it is not a variable, and even more so, variables cannot be called Cyrillic.
Follow the lesson carefully, google the rules for writing code in python, and good luck learning the language as soon as possible!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question