Here's the check50 terminal message:
:) Little Professor rejects level of 0
:) Little Professor rejects level of 4
:) Little Professor rejects level of "one"
:) Little Professor accepts valid level
:( At Level 1, Little Professor generates addition problems using 0–9
Did not find "6 + 6 =" in "Level: 0 + 4 =..."
:( At Level 2, Little Professor generates addition problems using 10–99
Did not find "59 + 63 =" in "Level: 15 + 43..."
:( At Level 3, Little Professor generates addition problems using 100–999
Did not find "964 + 494 =" in "Level: 876 + 5..."
:| Little Professor generates 10 problems before exiting
can't check until a frown turns upside down
:| Little Professor displays number of problems correct
can't check until a frown turns upside down
:| Little Professor displays EEE when answer is incorrect
can't check until a frown turns upside down
:| Little Professor shows solution after 3 incorrect attempts
can't check until a frown turns upside down
.
.
.
So...
I really don't know what it's trying to check so I can make the due changes.
Here's my code for evaluation:
import random
def main():
score = 0
level = get_level()
generate_integer(level)
for i in range(10):
chances = 3
x,y = generate_integer(level)
z = int(x + y)
while True:
try:
answer = int(input(f"{x} + {y} = "))
if answer == (z):
score += 1
chances = 3
break
else:
raise ValueError
except (ValueError, NameError):
print("EEE")
chances = chances - 1
if chances == 0:
print((f"{x} + {y} = {z}"))
chances = 3
break
print(f"Score: {score}")
def get_level():
while True:
try:
lvl = int(input("Level: "))
if 0 < lvl < 4 :
return lvl
elif lvl < 0:
pass
elif lvl > 3 :
pass
except (ValueError,TypeError):
pass
def generate_integer(level):
if level == 1:
x = random.randrange(9)
y = random.randrange(9)
if level == 2:
x = random.randrange(10,99)
y = random.randrange(10,99)
if level == 3:
x = random.randrange(100,999)
y = random.randrange(100,999)
return x,y
if __name__ == "__main__":
main()