I have this code:
import random
class Player:
def __init__(self):
self.first_name = set_first_name()
def set_first_name(self)
List = open("player/first_names.txt").readlines()
self.first_name = random.choice(List)
As you can see, I would like to set first name randomly from a text file. But I receive this error:
def set_first_name(self) ^ SyntaxError: invalid syntax
I assume it is not possible to call a class method within the initialisation of a class instance. At least not the way I am doing it. Could sombody give me a quick hint? I suppose there is an easy fix to this.
Thanks