So, I have this code:
playersList = []
nome = (input("Informe o nome do(a) jogador(a): "))
playersList.append({"Nome": nome, "Cérebros": 0})
print(playersList)
How do I get to increase that 0 value into 1?
CodePudding user response:
Like this:
playersList[0]["Cérebros"] = playersList[0]["Cérebros"] 1
print(playersList)
Output:
[{'Nome': 'nome', 'Cérebros': 1}]
CodePudding user response:
So you have a list called playerList
, and you added a dictionary with two keys.
To get the first item of the list you can use playerList[0]
To change Cérebros you can do playerList[0]["Cérebros"] = 1