For example:
I have:
max_points = 30
and i have a dict:
attri = {"strength": 0,"health": 0,"wisdom": 0,"dexterity":0}
Now i have a while loop and it asks a user a question:
add = int(raw_input("How many points would you like to add? "))
Now if i do this:
max_points -= attri ["strength"]It works fine and the max_points goes down as supposed to, but it doesnt save.
Like here:
attri ["health"] = add max_points -= attri["health"]
Now i need the previous max_points to save over onto when i subtract max_points again, but it resets to it's normal value (30).
full code:
#role playing attributes
#add = int(raw_input("How many points would you like to add? "))
attri = {"strength": 0,"health": 0,"wisdom": 0,"dexterity":0}
choice = None
max_points = 30
#str_points = count - points [0]
while choice != "4":
print \
"""
1. Spend your points
2. Check how many points you have
3. Remove points
4. Exit the game
"""
choice = raw_input("Choice? ")
if choice == "4":
print "Thanks for playing"
elif choice == "1":
quest = raw_input("Which attribute would you like to add points to? ")
if quest == "strength":
add = int(raw_input("How many points would you like to add? "))
attri ["strength"] = add
max_points -= attri ["strength"]
print "You have added ", add, "points to strength and have ", max_points, "remaining."
if quest == "health":
add = int(raw_input("How many points would you like to add? "))
attri ["health"] = add
print max_points
print "You have added ", add, "points to strength and have ", max_points, "remaining."
raw_input("x")


Sign In
Create Account


Back to top









