Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 months ago.
Improve this question
I tried running this basic python script to print something, and it doesn't seem to be executing properly.
name = "Tyler";
print{name};
I am getting this error:
File "C:\Users\tyler\main.py", line 2
print{name};
^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
I tried changing line 2 to:
print(...)
but it prints out
Ellipsis, not my name.
You don't need semicolons in Python
The issue was the use of curly braces. Call your variable name with print() like this:
name = "Tyler"
print(name)
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
Any ideas why this line isn't working? I want a variable to be assigned the integer of the text in a label. If the label does not have any text assigned, I want the variable to equal 0.
I'm getting a "can't assign to conditional expression" error before it even tries to run.
var = int(label.cget("text")) if label.cget("text") != "" else var = 0
More pythonic:
var = int(label.cget("text") or 0)
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I'm trying to make a simple console game in Python 2.7, where the user gets a dilemma and makes a decision by typing the number correlating to the option he wants to choose. This question is the main menu.
s = raw_input("Enter a number in the range 1 to %s\n> " % v
if (is_number(s) and s in q):
return s
I'm getting a "SyntaxError: Invalid syntax" from the if (is_number(s) and s in q) statemet when trying to run the program. It was working fine before i added the question.
This is my first real program.
You're missing a parentheses on the previous line:
s = raw_input("Enter a number in the range 1 to %s\n> " % v
# here--^
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I am trying read the contents of file through a variable
file = '/home/ec2-user/abc.txt'
paths = open("file","r+")
print paths.read()
But this is not working. I need help; I don't want specify 'abc.txt' directly.
First, you need to remove the quotes around "file":
paths = open(file,"r+")
When you're calling something using the value of a variable, you shouldn't quote the variable.
Second, if you don't want to hard code the path to file, you'll need to ask the user for it:
file = raw_input("Please enter the full path to the file: ")
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I'm getting crazy syntax errors in my terminal. For example:
end_result = ASCII_to_alpha_list(coded_list)
return ''.join(end_result)
Returns
End_result = ASCII_to_alpha_list(coded_list)
^
SyntaxError: invalid syntax
>>>
What's weirding me out especially is that it doesn't matter what I put down - it returns the same error.
print 'Hi'
returns
print "Hi"
^
SyntaxError: invalid syntax
>>>
Beginner coder here. Thanks for any help!
You almost certainly have an error on the line before, probably a missing close parenthesis.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 years ago.
Improve this question
I am new to this and am receiving an error that says print (line 5) is an invalid syntax
from random import randint
r=randint
while True:
s=int(input('How many sides would you like on your die')
print (r(1,s))
The problem is not actually on line 5, but on line 4. You have two ( brackets but only one ). In search of the final ) the Python interpreter checks the following line, and only at that point does it raise the error.
s=int(input('How many sides would you like on your die')
^
There is a closing parenthesis missing.