Loops - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Loops (/thread-15521.html) |
Loops - Programming_Noob - Jan-20-2019 #Game #Import module import random #Start randomgenerator random.seed() #Random values and calculation a= random.randint(1,10) b= random.randint(1,10) c= a+b print("The exercise:",a,"+",b) #Loop with [for] for i in 1,2,3,4: #Input print("Input number:") x=input() number= int(x) #Branch if number == c: print(number,"is correct") #Break of Loop break else: print(number, "is wrong") #End print("Answer:",c)when i try to run it, it says the 'break' is out of the loop. when imove it it says elif is a Syntax error. Need help RE: Loops - Larz60+ - Jan-20-2019 Quote:when i try to run it, it says the 'break' is out of the loop. when imove it it says elif is a Syntax error. Need helpYou don't have an elif. Please post exact unaltered and complete error message (in error tags) Your if/else is not part of loop, to make it so, indent 2 levels |