I'm trying to make a program that will generate a random list, length being determined by user input, that will be sorted. I'm having a problem accessing/passing my randomly generated list to other functions. For example, below, I can't print my list x. I've also tried making a function specifically for printing the list, yet that won't work either. How can I pass the list x?
unsorted_list = []
sorted_list = []
# Random list generator
def listgen(y):
"""Makes a random list"""
import random
x = []
for i in range(y):
x.append(random.randrange(100))
i += 1
return x
def main():
y = int(input("How long would you like to make the list?: "))
listgen(y)
print(x)
main()