Closed MrHalfs closed 8 months ago
import random def main(): i = 10 level = get_level() count = 0 wrong = 0 while i > 0: x, y = generate_integer(level) answer = x + y while wrong < 3: q = input(f"{x} + {y} = ") if q.isdigit(): q = int(q) if q == answer: count += 1 break else: wrong += 1 print("EEE") else: print("EEE") wrong += 1 continue if wrong == 3: print(f"{x} + {y} = {answer}") wrong = 0 i -= 1 print(f"Score: {count}") def get_level(): while True: level = input("Level: ") if level.isdigit() and level in "123": level = int(level) return level else: continue def generate_integer(level): one_ = random.randint(0, 9) one = random.randint(0, 9) two_ = random.randint(10, 99) two = random.randint(10, 99) three_ = random.randint(100, 999) three = random.randint(100, 999) if level == 1: x = one y = one_ return x, y elif level == 2: x = two y = two_ return x, y elif level == 3: x = three y = three_ return x, y if __name__ == "__main__": main()
when i run check50 i get this:
when i test the code and enter the same input as check50 the program runs properly.
when i run check50 i get this:
when i test the code and enter the same input as check50 the program runs properly.