Apr-05-2017, 08:09 PM
(Apr-05-2017, 06:24 PM)BlathaBlather Wrote: Say I had a list called 'rade' and in it was [1,2, 3, 4, 5,] and I also had another list called 'spam' and in it was [6, 7, 8, 9, 10,]
I want to input that I want to use the list 'rade'. How can I input it so it would work?
rade = [1, 2, 3, 4, 5, ] spam = [6, 7, 8, 9, 10] choice = input("Chose a list") if choice[1] == 2: print("Congratulations") else: print("Sorry...")
Neither... it's a very bad idea to code it like this. What you can do is either use an array:
lists=[[1, 2, 3, 4, 5, ],[6, 7, 8, 9, 10]] list_number = int(input("Chose a list: 1 for rade, 2 for spam")) chosen_list=lists[list_number-1]... or a dictionary:
lists={"rade":[1, 2, 3, 4, 5, ],"spam":[6, 7, 8, 9, 10]} list_name = input("Chose a list among: "+','.join(lists.keys())+": ") chosen_list=lists[list_name]
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Your one-stop place for all your GIMP needs: gimp-forum.net