0

My code is this

name = input("Enter Your Name : ")

print(name)

https://i.stack.imgur.com/UYykp.png

the Error that comes up is a Invalid syntax

no matter what code i use the invalid syntax is always on the first line

pls help

i have watched so many videos on youtube like: run from the console $ python myscript.py?

but nothing seems to work

if someone would help me i would appreciate it

1 Answers1

2

The syntax for accepting user input is different between major versions of Python. Specifically, from W3 Schools:

3.6

username = input("Enter username:")
print("Username is: " + username)

2.7

username = raw_input("Enter username:")
print("Username is: " + username)

Please share how you are running this. You can check your version by running the following command from a terminal.

python --version

tajacks
  • 71
  • 6
  • my version is Python 3.10.1 also how to I run my code in Sublime Text? – Crazy Cookie Dec 21 '21 at 22:59
  • Sublime text is just the editor, not the interpreter which actually runs your Python code. You can run your code by navigating to the directory which contains your .py file and do `python test.py`. Alternatively, use an IDE that can run it from the IDE itself, such as PyCharm. – tajacks Dec 22 '21 at 01:56
  • @tomjack Sublime has built-in [build systems](https://www.sublimetext.com/docs/build_systems.html) for running code within the editor, you don't need to switch to PyCharm. – MattDMo Dec 22 '21 at 17:37