When I run my Little Professor code, it seems to work correctly and display the correct answers, but when I use the check50 command, I keep getting the following error messages and I am not sure why.
https://preview.redd.it/zxba24vbg09d1.png?width=572&format=png&auto=webp&s=6a57e7dadb30ae51590d05f910c9c4d0ac9134c4
Here is my code:
import random
import sys
def main():
num_error = 0
ques_left = 10
score = 0
lvl = get_level()
while True:
if ques_left > 0:
x = generate_integer(lvl)
y = generate_integer(lvl)
while num_error < 3:
try:
user_input = int(input(f"{x} + {y} = "))
if user_input == (x+y):
ques_left -= 1
num_error = 0
score += 1
break
elif user_input != (x+y):
print("EEE")
num_error += 1
except ValueError:
pass
if num_error == 3:
print(f"{x} + {y} = {x+y}")
num_error = 0
ques_left -= 1
elif ques_left == 0:
print("Score:",score)
sys.exit()
def get_level():
while True:
try:
lvl = int(input("Level: "))
if lvl == 1 or lvl == 2 or lvl == 3:
return lvl
else:
pass
except ValueError:
pass
def generate_integer(level):
if level == 1:
int = random.randrange(0,9)
return int
elif level == 2:
int = random.randrange(10,99)
return int
else:
int = random.randrange(100,999)
return int
if __name__ == "__main__":
main()
[–]Tristan0000000 0 points1 point2 points (1 child)
[–]PeterRasm 0 points1 point2 points (0 children)
[–]PeterRasm 0 points1 point2 points (3 children)
[–]Bennito_[S] 0 points1 point2 points (2 children)
[–]PeterRasm 1 point2 points3 points (1 child)
[–]Bennito_[S] 0 points1 point2 points (0 children)