I am trying to pass a list as a parameter to a class. Should I be enumerating or indexing the list before sending it somehow?
class Player:
def __init__(self,con,int,wis,str,dex):
self.con = con
self.int = int
self.wis = wis
self.str = str
self.dex = dex
def navigate(self):
print("The player is navigating")
def swing(self):
print("The player swings and gets a random
swing score added to his dexterity")
def heals(self):
print("The player takes a restorative
tincture")
import random
player_stats = random.sample(range(6, 18), 5)
player_1 = Player(player_stats)
The error I am getting is this:
player_1 = Player(player_stats)
TypeError: Player.__init__() missing 4 required positional arguments: 'int', 'wis', 'str', and 'dex'
However, if I send the 5 attributes manually, as in
player_1 = Player(18,17,16,15,14)
The program accepts it without errors.