Append to Python dictionary from method

前端 未结 3 562
终归单人心
终归单人心 2021-01-27 12:27

I have this dictionary called biography

self.biography = {\'Name\' : \'\', \'Age\' : 0, \'Nationality\' : \'\', \'Position\' : 0, \'Footed\' : \'\'}
3条回答
  •  终归单人心
    2021-01-27 13:31

    def create_player(self):
        self.biography['Name'] = input('Player name: ')
        self.biography['Age'] = int(input('Player age: '))
        self.biography['Nationality'] = input('Nationality: ')
        self.biography['Position'] = input('Position: ')
        self.biography['Footed'] = input('Footed: ')
    

    try this.

提交回复
热议问题