'How can I store each value from a list to multiple variables?
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.
Solution 1:[1]
I don't know if this is what you're looking for, but:
events = ["Football", "Volleyball", "Badminton"]
one = events[0]
print(one)
Solution 2:[2]
You can just try:
event1,event2,event3 = events
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | 0x5453 |
| Solution 2 | 0x5453 |
