Hi
I keep getting invalid syntax with the below:
if (row[0] == year) and (row[1] == month) and (row[2] == day and (row[3] == hour) and (row[4] == minute):
print "hello"
else:
print "hello2"
Any ideas?
Hi
I keep getting invalid syntax with the below:
if (row[0] == year) and (row[1] == month) and (row[2] == day and (row[3] == hour) and (row[4] == minute):
print "hello"
else:
print "hello2"
Any ideas?
You're missing a closing parenthesis:
if (row[0] == year) and (row[1] == month) and (row[2] == day and (row[3] == hour) and (row[4] == minute):
^^^
Also, beware indentation.
Try:
if row[0:5] == [year, month, day, hour, minute]:
That fixes your error and makes the whole thing much more readable.
If "row" is a list, you can do this instead (for clarity):
if row[:5] == [year, month, day, hour, minute]:
..or if row is a tuple:
if row[:5] == (year, month, day, hour, minute):
You have 5 superfluous left parentheses but only 4 superfluous right parentheses. Consider losing ALL the parentheses!