Why won't my program work in python? -
hi 11 yrs old , teaching myself how code. set myself task make times table quiz asks 10 questions , inputs random numbers. however, code not working , not know why. using python 2.7.5. code:
print("here quiz test knowledge") print("") print("question 1") import random print random.randint(1,10) print ("times") import random print random.randint(1,10) answer = raw_input ("make choice: ") if answer == ran1*ran2: print "that correct" correct=correct +1 else: print "that incorrect!"
i can not spot why not working have not put loop in yet asks 1 question. when run else highlighted in red not know why.
python works without brackets. replaced "spaces or tabs". , import once, beginning.
this should work
import random print("here quiz test knowledge") print("") print("question 1") print random.randint(1,10) print ("times") print random.randint(1,10) answer = raw_input ("make choice: ") if answer == ran1*ran2: print "that correct" correct=correct +1 else: print "that incorrect!"
Comments
Post a Comment