people = {"a":0, "b": 0, "c": 0, "d": 0}
def changes(option):
if option == 1:
person = input("Who would you like to add points to? ")
print(person)
amount = input("How many points would you like to add to " + str(person) + "?")
people[person] += amount
print("SUCCESSFULLY UPDATED: " + person + " now has " + str(people.person) + " points")
Asked
Active
Viewed 32 times
-2

mkrieger1
- 19,194
- 5
- 54
- 65
-
1Please post the full traceback. – Barmar Jul 25 '21 at 13:40
-
And show what you entered to the prompts. – Barmar Jul 25 '21 at 13:41
-
`amount` is a string, you can't add it to a number. – Barmar Jul 25 '21 at 13:41
-
`person` is a string, you don't need to use `str(person)`' – Barmar Jul 25 '21 at 13:42
-
`people.person` should be `people[person]` – Barmar Jul 25 '21 at 13:42
-
If `amount` is supposed to be a number - and it is, convert it: `amount = int(input(...))`. Also, you should have a look at [string formatting](https://stackoverflow.com/questions/5082452/string-formatting-vs-format-vs-f-string-literal) rather than rely on concatenating pieces of strings. – Thierry Lathuille Jul 25 '21 at 13:46
2 Answers
0
Replace str(people.person)
with people[person]
Because you are trying to access people['person']
otherwise.

Timothy Alexis Vass
- 2,526
- 2
- 11
- 30
0
person is not a key, It's a variable that holds the key.
This will work:
people = {"a":0, "b": 0, "c": 0, "d": 0}
def changes(option):
if option == 1:
person = input("Who would you like to add points to? ")
print(person)
amount = int(input("How many points would you like to add to " + str(person) + "?"))
people[person] += amount
print("SUCCESSFULLY UPDATED: " + person + " now has " + str(people[person]) + " points")
changes(1)

Abhi
- 995
- 1
- 8
- 12