I need help with my code... I can't tell whats wrong with the else:


#1

import time
for i in range (2):
print(’…thinking…’)
time.sleep(2)
else:
print (‘It was a Yes or No question…’)
import time
for i in range (2):
print(’…thinking…’)
time.sleep(2)

It says the else: is a syntax error ,but I’ve worked on this for over 20 minutes and can’t tell what’s wrong…


#2

else has to be after an if or an elif:

if condition:
   print "do something"
else:
   print "do something else"

in your case, else is after time.sleep(2), which it can’t be. sleep either shouldn’t be there, or it should be indented/nested into the if clause/code block