Reputation: 3842
I'm doing a real silly mistake in Python but unable to find what it is
I'm doing something like this in python
filename="file1"
if name == 'file1'
print 1
I'm getting an invalid syntax error
Upvotes: 1
Views: 1720
Reputation: 342313
what is name?? did you define it elsewhere?? I assume its "filename" instead, so
filename="file1"
if filename == 'file1':
print 1
if "name" is defined, then the problem is indeed the ":" at the end of "if" line.
Upvotes: 1
Reputation: 55445
You need to put a colon at the end of the if statment
filename="file1"
if name == 'file1':
print 1
Upvotes: 4
Reputation: 304137
You are missing a colon
filename="file1"
if name == 'file1':
print 1
Upvotes: 7