Hello and apologies if a similar question has been answered, but I cannot find similar post. I am still rather new with python 3 and English is a little rough.
I start the program and it goes to character_start() where it ask for a name and sets a health variable to 10. It then calls the main() where it says the health again and it ask the user where they want to go. As for now the only option is 1 and that takes you to the trap() function. The user will be hit by 1 health and it should go back to main() where it will show them with 1 missing health.
I think the problem is it does not recognize the user_health as a global variable even when I write it outside of a def.
Thank you and here is my code.
import random
def character_start():
user_name = input("Name: ")
user_health = 10
main()
def main():
print("Health: ", user_health)
print("Type 1 to walk into a trap.")
main_choice = int(input("Choice: "))
if (main_choice == 1): trap()
def trap():
user_health = user_health - 1
print("1 point of damage.")
main()
character_start()