Home > Mobile >  How can I store each value from a list to multiple variables?
How can I store each value from a list to multiple variables?

Time:04-19

I have created a list that is generated from the user's inputs in my own code but I also wish to store each of the values in that list to separate variables. For example, if I have the list events = ["Football", "Volleyball", "Badminton"] and want to store football, volleyball, and badminton all into different variables such as event1, event2, and event3 is that possible? Unfortunately, I have been unable to come up with something that works. Any help is appreciated.

CodePudding user response:

I don't know if this is what you're looking for, but:

events = ["Football", "Volleyball", "Badminton"]
one = events[0]
print(one)

CodePudding user response:

You can just try:

event1,event2,event3 = events
  • Related