attributes = {"Health": 0, "Strength": 0, "Dexterity": 0,
"Intelligence": 0}
points = 40
def add_points(attributes):
type = input("Which attribute would you like to adjust?: ")
if type in attributes:
how_many = int(input("Add how many points?: "))
if how_many <= points:
type += how_many
return type
add_points(attributes)
Some context. The code above is a piece of my character creator program I am building. I have the entire program written, however I want to use a function rathre than typing a bunch of loops. Trying to make my code more concise and Pythonic.
I cannot figure out how to take the value of whatever key is chosen by the user and add x amount of points (also chosen by the user) to the value assigned to said key.
Any help would be greatly appreciated!