: ( Little Professor displays number of problems correct Cause: Did not find "9" in "Level: 6 + 6 =..."

Everything test worked fine except, Little Professor displays number of problems correct Cause: Did not find "9" in "Level: 6 + 6 =..."

``````

def main():
level = get_level()

rounds = 10
points = 0
retries = 0

while rounds > 0:
if rounds == 0:
print("Score", points)
two_rand_num = list(generate_integer(level))
if retries == 0:
x = two_rand_num[0]
y = two_rand_num[1]
try:
rounds -= 1
points += 1
retries = 0
continue
else:
raise ValueError
except (ValueError, NameError):
print("EEE")
retries += 1
pass
if retries == 3:
rounds -= 1
retries = 0
continue

def get_level():

while True:
try:
except ValueError:
pass

def generate_integer(level):
if level == 1:
x = random.randint(0,9)
y = random.randint(0,9)
elif level == 2:
x = random.randint(10,99)
y = random.randint(10,99)
elif level == 3:
x = random.randint(100,999)
y = random.randint(100,999)
return x,y

if __name__ == "__main__":
main()
``````

Here is the link to see it more details: https://submit.cs50.io/check50/90fcfbf499b81a5e6904fab16229d886cb8c3250

When `rounds` is 0, the `while loop` exits This line `if rounds == 0:` never evaluates to `True`.
• changed `if rounds == 0` to the end of the main's while loop, removed `if` since the while loop is done, but got the same error. Commented Dec 16, 2023 at 16:01
• when i run the posted code (added `import random`) it doesn't output the score. Commented Dec 21, 2023 at 11:22