Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Troubling question
#1
Hello everyone,

I need to find out how to see if the users answer is correct. In this, the answers are randomly generated and the user has to input an answer and the program will check if it is correct or nott.Could someone please help, i will input my existing code.
import random
print('Random number generator')
lowest_option= int(input('What is the lowest option? '))
highest_option= int(input('What is the highest option? '))

counter = 0

for count in range(5):
    limit1 = random.randint(lowest_option, highest_option)
    limit2 = random.randint (lowest_option, highest_option)
   
    player_answer = int(input('What is the answer to' + str(limit1) + '+' + str(limit2) + ' ?'))
Reply
#2
Use
correct = player_answer == limit1 + limit2
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020