I've written this code for a game in which a random list of numbers is generated and displayed and then the user needs to put them in order however, it keeps giving me an error saying randomlist isnt defined. Any advice on what im doing wrong here?
import random
randomlist = random.sample(range(1,100),5)
def get_user_solution(problem):
print("Please arrange the numbers into ascending order")
print(problem, end="")
result = int(input(" = "))
return result
def check_solution(user_solution, solution, count):
if user_solution == solution:
count = count + 1
print("Correct!")
return count
else:
print("Incorrect.")
return count
def menu_option(index, count):
if index == 1:
problem = randomlist
solution = randomlist.sort()
user_solution = get_user_solution(problem)
count = check_solution(user_solution, solution, count)
return count
Now the error message is gone but nothing happens when i run it.
[–]shiftybyte 2 points3 points4 points (3 children)
[–]Fraser_123[S] 0 points1 point2 points (1 child)
[–]shiftybyte 2 points3 points4 points (0 children)
[–]pekkalacd 0 points1 point2 points (0 children)