def Change_char_stats():
Char_dmg = 50
Char_health = 100
Char_stat_choice= ''
print('Current Damage is:',Char_dmg,'and health is:',Char_health,'.')
Char_stat_choice=input('\nWhat character stat would you like to edit?')
if Char_stat_choice == '1':
print('Current damage is',Char_dmg,'.')
Char_dmg=int(input('Character damage to: '))
print('Character damage has been changed to',Char_dmg,'.')
Change_char_stats()
elif Char_stat_choice == '2':
print('Current damage is',Char_health,'.')
Char_health=int(input('Character health to: '))
print('Character health has been changed to',Char_health,'.')
Change_char_stats()
else:
print('Input invalid.')
Change_char_stats()
Change_char_stats()
So basically I'm working on a simple game for myself on Python, and I'm having an issue with my variables as when I run the program original variables are set to 50 dmg and 100 health, but what I want to do is be able to run the code, change the variables and then have them stay as that. Although I understand why the variables aren't staying as the new values, I have no clue how to over-write them, help would be much appreciated.
Thanks.
'on this lineChar_stat_choice=input('\nWhat character stat would you like to edit?)Change_char_stats()recursively but you don't keep track of any changes done toChar_healthetc. It might be better to have a character represented as an instance of a class so that you can keep track of changes.ifstatements belong inside theChange_char_stats()function?