This question already has answers here:
Using print() (the function version) in Python2.x
(3 answers)
Closed 6 years ago.
I am currently coding a slot-like game, and everything seems to work besides this one thing:
File "/Users/r/Desktop/Game.py", line 36
print(one, end = " ")
^
SyntaxError: invalid syntax
Does anyone know how to fix this?
Are you trying to pass a Boolean for the second parameter to print?
In that case you want print(one, end == ' ')
Related
This question already has answers here:
if/else in a list comprehension
(12 answers)
Closed 2 years ago.
mersenne_list = [mersenne_number(p) for p in the list_prime]
^
SyntaxError: invalid syntax
i entered the above code and it gave me this error, which syntax is missing, please
You need to remove the in the to just in
mersenne_list = [mersenne_number(p) for p in list_prime]
you can read more about in here
Remove the:
mersenne_list = [mersenne_number(p) for p in list_prime]
Python saw two names separated by a space which is invalid syntax.
This question already has answers here:
How to fix syntax error when printing a string with an apostrophe in it? [closed]
(6 answers)
Closed 3 years ago.
bob = input('How old are you? ')
print('You're', bob)
It's giving me syntax error because im using ' for you're. Whats the correct way of handling sentences with ' in them?
There are at least two ways to do this:
Use " for your string: "You're".
Escape the single quote: 'You\'re".
This question already has answers here:
Python 3: EOF when reading a line (Sublime Text 2 is angry)
(5 answers)
Closed 5 years ago.
name = input('Hey what is your name?: ')
print('nice to meet you ',name)
Whenever I try to run this I receive the following error :
"EOF when reading a line".
Could anyone help me with this?
Just a guess: you need to run this in a terminal (it does work when run like this). I am thinking that your code does not have any chance to get any input (hence the End Of File warning).
This question already has answers here:
Why is parenthesis in print voluntary in Python 2.7?
(4 answers)
Syntax error on print with Python 3 [duplicate]
(3 answers)
Closed 6 years ago.
I haven't done much with Python, but the code-academy course has seemed to give me some enjoyment however when I have taken my project to the actual python compiler I get an error compiling. Highly possible that code-academy just hasn't updated to a more recent version, as I've seen here that people have used this previously.
C:\Python>battleship.py
File "C:\Python\battleship.py", line 10
print " ".join(row)
^
SyntaxError: invalid syntax
For some reason I am having issues placing the source in the question, as this is my first question, so ill describe the code. Using an empty list there is a "board" created to play battleship on, with a for loop that loops through a set range appending < board.append["O"] * 5 >. Then it loops through each row in the array and then uses < print " ".join(row) >
How can I get by this and is there an alternative way that is better?
Edit: Python version 3.5.2
This question already has answers here:
Syntax error on print with Python 3 [duplicate]
(3 answers)
Closed 9 years ago.
Once again Python's helpful error messages make me eat my keyboard.
I've checked the whole script forwards and backwards but can't find any "syntax error(s)".
Is there a decent debugger for Python or a helpful website which is able to scan my code for errors?
C:\Users\Daapii\Desktop>"foo.py"
File "C:\Users\Daapii\Desktop\foo.py", line 26
print "test"
^
SyntaxError: invalid syntax
Python why u no tell me more!
If this is Python 3, then the print function now requires parenthesis. Try print("test").
(EDIT: If Python continues to make you want to eat your keyboard, this might help.)
print is a function in Python 3:
print ("test")
Find other changes here: docs