for some reason I can't figure out why my code prints "None" after printing something out of a class or how to remove it. This is my code:
class armour:
def __init__(self, name, defence):
self.name = name
self.defence = defence
def block(self):
print("your " + self.name + " blocked " + str(self.defence) + "\n")
class weapon:
def __init__(self, name, attack):
self.name = name
self.attack = attack
def attacks(self):
print("your " + self.name + " blocked " + str(self.attack) + "\n")
loot = {
"id1" : armour("test 1", 10),
"id2" : weapon("test 2", 10),
}
equipment = {
"armour" : loot["id" + str(1)],
"weapon" : loot["id" + str(2)],
}
print(equipment["armour"].name)
print(equipment["armour"].block())
print(equipment["weapon"].name)
print(equipment["weapon"].attacks())
If anyone could also explain why it is happening it would be appreciated.