I want to ask the user which list they would like to access, then retrieve that list. I dont really have any code for this, because I'm currently just brainstorming. I couldn't really find a proper answer so here is a sample code I just made for the sake of explaining what I'm trying to do:
list1=[1, 2, 3, 4, 5]
list2=[6, 7, 8, 9, 10]
list3=['s', 'r', 't', 'd']
user_input=input('which list do you want to access')
I know that I can use if and elseif statements but the code I plan on making will have a large number of lists and I want a more efficient way to achieve this.
mylist={ }thenmylist["1"] = [1, 2, 3, 4, 5]etc. Then ask the user for a number in the range 1..3 and get the desired list like this:mylist[user_input].