Jan-08-2020, 10:44 PM
So, I want to create a class, that has a few items inside. (sorry if I don't use the correct terms I'm new to Python)
for example:
You opened basic crate and got a basic sword!
rather than:
<__main__.basic object at 0x7efec00d9450>
Thanks!
class Basic(): def __init__(self, item, attack, sell_price, buy_price): self.item = item self.attack = attack self.sell_price = sell_price self.buy_price = buy_price basic_sword = basic('basic Sword', 10, 50,25) basic_spear = basic('basic spear', 15, 25, 30) basic_gloves = basic('basic gloves', 5, 8, 10) basic_knife = basic('basic knife', 10, 25, 35) starting_crate = [basic_sword, basic_spear, basic_gloves, basic_knife]So, how would I go about getting a random object from the starting_crate list and print out ONLY the item name part using the random module?
for example:
You opened basic crate and got a basic sword!
rather than:
<__main__.basic object at 0x7efec00d9450>
Thanks!