#πŸ”’ Very basic issue

15 messages Β· Page 1 of 1 (latest)

dull hearth
#

Hey I'm extremely new to coding and I am going through CS50-P

My code works in the bug terminal but doesn't work when i press go in the normal window. it says santax error but its identical to the CS50-P code and it worked yesterday.

Any help would be appreciated. Im guessing its a quick fix?

umbral knollBOT
#

@dull hearth

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

eager forum
#

!repl you're inside the python interactive console (aka REPL), you gotta exit it before running the program

umbral knollBOT
#
Read-Eval-Print Loop (REPL)

A REPL is an interactive shell where you can execute individual lines of code one at a time, like so:

>>> x = 5
>>> x + 2
7
>>> for i in range(3):
...     print(i)
...
0
1
2
>>>

To enter the REPL, run python (py on Windows) in the command line without any arguments. The >>> or ... at the start of some lines are prompts to enter code, and indicate that you are in the Python REPL. Any other lines show the output of the code.

Trying to execute commands for the command-line (such as pip install xyz) in the REPL will throw an error. To run these commands, exit the REPL first by running exit() and then run the original command.

eager forum
#

Just exit() and hit enter

dull hearth
#

in the terminal?

eager forum
#

Yep

wet nymph
#

VSCode enters the syntax it needs to down in the terminal in order to execute your python script. It can't do that correctly when you're in the REPL as has been described.

dull hearth
#

how can i tell that I was in REPL?

wet nymph
#

>>>

dull hearth
#

ahh ok thanks

#

i really appreciate both your help

wet nymph
#

You're welcome!

umbral knollBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.