RE: Python Libraries: The Random Splash Voter
(Edited)
You are viewing a single comment's thread:
I still don’t understand why the (type(voterlist)) command returns a list
I guess it is "active_votes": ["trayciyork","slobberchops","steevc"], hence voterlist=["trayciyork","slobberchops","steevc"], which naturally returns a list as a type
Had to edit the comment to add a suggestion to deal with duplicate votes - to keep a list of items voted on. So if true, vote, add to the list, check if on the list if not, check if true, vote, add to the list...
Just an idea
0
0
0.000
If you print what (voterlist) returns.. this is what it looks like:
Those pairings are the hallmarks of a dictionary variable, and yet it insists it's a list.
ok, still a list type ( or better say a list of dictionaries):
[ { }, { }, { } ... { } ]
Since it's
[]
, it's a list.From what I can see, [] is a list, and {} is a dictionary, so [{}], .. is as @rimicane says, a list of dictionaries.
Dictionary
List
It seems there is a such a thing, which I wasn't aware of. The regular 'in' operator as a search does not work on this type so I just messed around with it until I found something that did!
https://pythonexamples.org/python-list-of-dictionaries/
It's a list of JSONs, actually.
Something like this should work.
Yes, that's exactly what I used.