When I run the code below, I get a syntax error on the elif line. I've double checked my code block containing the elif statement and also researched similar issues on this forum, but nothing has answered my question. I'm assuming that it has something to do with white space, however, the spacing looks fine and Notepad++ says my If, elif, and else statements have the same indentation.
Also something to note. Sometimes when I open my code using Python IDLE, I'll get some strange spacing around the elif portion of the code which doesn't appear in Notepad++. Why does that happen? I've tried fixing the spacing inside of IDLE, but that hasn't worked either. Any ideas?
while True:
money_rounded = round(total_cash, 2)
if second_counter > 3600:
seconds = second_counter%60
hours = int((second_counter/60)/60)
minutes = second_counter/60
while minutes > 60:
mintues = minutes - 60
print("You have earned ${} in {} hour(s), {} minute(s), and {} second(s).".format(money_rounded, hours, minutes, seconds)
elif second_counter > 60:
seconds = second_counter%60
minutes = int(second_counter/60)
print("You have earned ${} in {} minute(s) and {} second(s).".format(money_rounded, minutes, seconds))
else:
print("You have earned ${} in {} seconds.".format(money_rounded, time_counter))
Aucun commentaire:
Enregistrer un commentaire