Jun-17-2020, 12:16 PM
Trying to make a small program where a user can answer basic questions (1+1 etc). But the questions should be random, in my code, no random numbers are generated. Is the for loop in wrong place?
import random from random import randrange x = random.randrange(0, 101) y = random.randrange(0, 101) sum = (x + y) for sum in range(1, 5): a = int(input(f'What is {x} + {y}? ')) if a == sum: print('Correct') else: print(f'Not correct, the correct answer is {sum}.')