Aug-22-2022, 07:58 AM
(Aug-21-2022, 08:06 PM)fozz Wrote:channels = [ ['#channel1', 0], ['#channel2', 0], ['#channel3', 0], ]
Assigning the first element from channels to a name:
first = channels[0]Assigning a list to the first element of the list
channels
:channels[0] = ["channel33", 33]If you do not want to use integer indices, then use a dict.
channels = { '#channel1': 0, '#channel2': 0, '#channel3': 0, } channels['#channel4'] = 33 channels['#channel1'] = 1 for name, value in channels.items(): print(name, "->", value)
Output:#channel1 -> 1
#channel2 -> 0
#channel3 -> 0
#channel4 -> 33
Getting all values, but not the channels (keys of the dict):print(list(channels.values()))
Output:[1, 0, 0, 33]
If you use for your program the wrong data structures, then handling the data is very complicated.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!