I’ve just started using Python and Sublime Text, I wrote this simple program:
forename = input("What is your forename? "); print("Hello" + forename + "/n"); print("/n");
but the problem is when I run the program it says:
statement ends with a semicolon, no new line at the end of the file, I’ve tried removing the semicolons
Remove the semicolons and use
raw_input instead of
input and then go from there.
But then Sublime Text says:
"Traceback (most recent call last):
File “C:\Users\apollo\Desktop\Python\One.py”, line 1, in
forename = raw_input("What is your forename? “)
NameError: name ‘raw_input’ is not defined
[Finished in 0.2s]”
I’m using Sublime Text 3 and python latest one[3.5]
Yeah ok, in Python3 you should be using
input. It’s the same function as Python2’s
raw_input, the other one got removed since it usually wasn’t what anyone ever wanted and it can be reproduced by combining some other functions (
eval(input())) … and
eval is in nearly all cases also something to avoid.
The semicolons shouldn’t be there though, Python uses newline characters to terminate statements. Semicolons can be used to write multiple statements on the same line but that’s uncommon and you can essentially safely forget that semicolon exists.