Currently this program will ask you which of two numbers is bigger. To get a higher grade i need to change it so that it is randomly asking which one is bigger or smaller. How would i edit my existing code to do this?
while True: import sys import random user_name = input("Whats your name?") choice = input("{}, do you want to do custom or leveled difficulty?".format(user_name)) if choice == "custom": custom_range_1 = int(input("Pick a number to be the lowest.")) custom_range_2 = int(input("Pick a number to be the highest.")) number_range = [custom_range_1,custom_range_2] first_custom_random = (int(random.randrange(custom_range_1, custom_range_2))) second_custom_random = (int(random.randrange(custom_range_1, custom_range_2))) print(first_custom_random, second_custom_random) user_anwser = input("Which is bigger, the first number or the second?") if user_anwser == ("2") and second_custom_random > first_custom_random: print("Correct!") elif user_anwser == ("1") and second_custom_random < first_custom_random: print("Correct!") else: print("Sorry thats wrong!") restart_choice = input("Do you want to restart?") if restart_choice == ("no"): print("bye!") sys.exit([arg]) if restart_choice == ("yes"): continue elif choice == "leveled": level_choice = input("Which level would you like? Pick 1, 2, or 3") if level_choice == ("1"): points = 0 while points < 3: leveled_range_1 = [1,100] level_1_random_1 = (int(random.randrange(1, 100))) level_1_random_2 = (int(random.randrange(1, 100))) print(level_1_random_1, level_1_random_2) user_anwser = input("Which is bigger, the first number or the second?") if user_anwser == ("2") and level_1_random_2 > level_1_random_1: print("Correct!") points += 1 print("You have {} points".format(points)) elif user_anwser == ("1") and level_1_random_2 < level_1_random_1: print("Correct! Thats 1 more point!") points += 1 print("You have {} points".format(points)) else: print("Sorry thats wrong!") points -= 1 print("You have {} points".format(points)) continue print("LEVEL 2") level_choice = ("2") if level_choice == ("2"): points = 0 print("Begin level 2!") while points < 3: level_2_random_1 = (int(random.randrange(1, 1000))) level_2_random_2 = (int(random.randrange(1, 1000))) print(level_2_random_1, level_2_random_2) user_anwser = input("Which is bigger, the first number or the second?") if user_anwser == ("2") and level_2_random_2 > level_2_random_1: print("Correct!") points += 1 print("You have {} points!".format(points)) elif user_anwser == ("1") and level_2_random_2 < level_2_random_1: print("Correct! Thats 1 more point!") points += 1 print("You have {} points!".format(points)) else: print("Sorry thats wrong!") points -= 1 print("You have {} points!".format(points)) continue print("LEVEL 3!") level_choice = ("3") if level_choice == ("3"): points = 0 print("Begin level 2!") while points < 3: level_3_random_1 = (int(random.randrange(1, 10000))) level_3_random_2 = (int(random.randrange(1, 10000))) print(level_3_random_1, level_3_random_2) user_anwser = input("Which is bigger, the first number or the second?") if user_anwser == ("2") and level_3_random_2 > level_3_random_1: print("Correct!") points += 1 print("You have {} points!".format(points)) elif user_anwser == ("1") and level_3_random_2 < level_3_random_1: print("Correct! Thats 1 more point!") points += 1 print("You have {} points!".format(points)) else: print("Sorry thats wrong!") points -= 1 print("You have {} points!".format(points)) continue print("You won the game!!!!!!!!!!!!!!!!!!~!!!!!!!!!") restart_choice = input("Do you want to restart?") if restart_choice == ("no"): print("bye!") sys.exit([arg]) if restart_choice == ("yes"): continue
Moderator nilamo: Please use code tags in the future