0
Python Argument Help
I am trying to get my code to save two arguments instead of just one. Simply put, 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?
6 odpowiedzi
0
I want to be able to print the weapon's name and ammo count to create something like this.(the code doesn't compile correctly, however, this is the general idea
https://code.sololearn.com/c64EnMckKUDs/?ref=app
+ 1
use dictionary to contain key and value pair
{'weapon':ammo}
+ 1
as you asked you require a method to store name of weapon and ammo count so using dictionary instead of list will solve the problem eg:-
{"swards":25}
+ 1
you are already storing ammo in object why you need to store again
https://code.sololearn.com/clFbR0Rj4z2y/?ref=app
0
what do you mean? or what would that look like?
0
this is the part of my code that I am testing. it is really messy, but how would I fix this with dictionaries?
https://code.sololearn.com/c9DG07ezqdNw/?ref=app