0

How can I fix my code?

I made my code choose a random number. Based on the number generated, the player receives a different item. However, I'm trying to add weapons with different ammo counts into a broad (list?) basically: items = [] this list contains swords as well. So, how can I place items in there, that have a name and an ammo count? sorry it's so messy. and thanks in advance :D https://code.sololearn.com/c9DG07ezqdNw/?ref=app

17th Jan 2018, 4:22 PM
Stef
Stef - avatar
7 Respostas
+ 11
might wanna look into a dictonary? myDic={"wand":6, "milk":2} print(myDic["milk"])
17th Jan 2018, 4:52 PM
Ahri Fox
Ahri Fox - avatar
+ 6
@Stef myDic["milk"]-=1
29th Jan 2018, 1:09 AM
Ahri Fox
Ahri Fox - avatar
+ 3
.... walking on thin ice with those arguments XD
18th Jan 2018, 3:30 PM
Stef
Stef - avatar
+ 3
@Ahri MyDic ??? Sounds something diff
19th Jan 2018, 9:55 AM
Fire Feathers
Fire Feathers - avatar
+ 1
but how could i subtract one from milk in this instance? so instead of 2 it becomes 1?
18th Jan 2018, 3:31 PM
Stef
Stef - avatar
+ 1
I'm trying to create something like this https://code.sololearn.com/c64EnMckKUDs/?ref=app
18th Jan 2018, 3:31 PM
Stef
Stef - avatar
0
thx :)
29th Jan 2018, 2:28 AM
Stef
Stef - avatar