0

Dictionary

Can anyone give more exaples of dictionaries? Like from games or smthing

5th Mar 2021, 8:15 AM
Kul Bart
Kul Bart - avatar
4 Respostas
+ 2
Can you provide a bit of an example of what you are looking for. Otherwise, the Python tutorials give very good examples of dictionary uses.
5th Mar 2021, 10:33 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
I mean i want to know where i can use dictionaries. Numbers, words or colors don't work with me. I am looking for example like from games because i like games. Can i use dictionary to categorise weapons like this: weapons={ "sword" :["long sword", "excalibur", "dagger"] "axe" :["machete"... Etc] } Can it be used like this?
5th Mar 2021, 10:43 AM
Kul Bart
Kul Bart - avatar
+ 1
Kul Bart copy this to play with: weapons = { 'swords': ['long','short','broad'], 'knives': ['dagger','dirk','razor'], 'clubs' : ['mace', 'staff', 'flail'] } print(weapons['swords'],'\n') [print(i) for i in weapons['knives']] print() print('mace' in weapons['clubs'])
5th Mar 2021, 10:57 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
Thanks
5th Mar 2021, 12:14 PM
Kul Bart
Kul Bart - avatar