my program seems to be working appropriately while completing the problem's requirements.
I don't know if my solution is just outright wrong or what is happening really.
Here's my code :
#prompt user for lvl between 1,2,3. If not one of those 3, prompt again -> done
#generate 10 random addition problems -> done
#each operator should be positive number+done
#prompts user for their solution to each pb-> done
#allows 3 errors per pb -> done
#after each error display EEE and reprompt->done
#if errors>3 for a single pb, show solution->done
#ultimately ouput total score of user out of 10->done
import random
def main() :
generate_integer(get_level())
def get_level():
while True:
x= input("choose lvl ")
ok_lvl = ["1","2","3"]
if x in ok_lvl:
return x
else :
continue
def generate_integer(level):
start=0
score = 10
while start<10:
liste = list()
for i in range (2):
n = round(random.uniform(1,10), 2)
if level =="1":
liste.append(round(n))
else :
num_level=int(level)
n=(round(n * 10**(num_level-1)))
liste.append(n)
result = liste[0] + liste[1]
while True:
attempt = 0
while attempt<3 :
user_answer = input(f"{liste[0]} + {liste[1]} =")
if int(user_answer) == result:
start += 1
break
else:
print("EEE")
attempt= attempt +1
continue
break
if attempt==3:
print(f"{liste[0]} + {liste[1]} = {result}")
score-=1
start+=1
print(score)
if __name__=="__main__":
main()
Thanks a lot for the help !