+ 1
invoke items from class in a function in python
I have a class like this: class Person: def __init__(self, hp,mp,atk, df, magic): self.maxhp = hp self.hp = hp self.maxmp = mp self.mp = mp self.atkl = atk - 10 self.atkh = atk + 10 self.df = df self.magic = magic self.actions = ["Attack", "Magic"] and a function like the following: def choose_action(self): i = 1 print ("actions") for i in self.actions: print(str(i) + ":", item) i += 1 my question is: how can I invoke the items of actions from the function? in order to get the output like this: actions: 1: attack 2: magic thank you
1 Resposta
+ 6