0
having a problem with defining HELP pls!
import time import pygame def woods(): woods_options =["1","2"] user_choice ="" print("i wake up in the woods it is pitch dark i can only see a light") print("i should head towards the light") time.sleep(2) print() print("i arrive and hear screaming") print("should i go in or around") print() print("1, go in") print("2, go around") print("select 1 or 2") user_choice = str(input("enter option number: ")) print("you have selected:" + user_choice) if user_choice == woods_options[0]: house() elif user_choice == woods_options[1]: woods02() def house(): print("you have entered the house") Everything works in it except when I press 1 it says woods options not defined
2 Antworten
+ 1
woods_options is defined inside a function so you can use it only inside that function (add global woods_options before defining it if you want it to be in the global scope so you can use it outside the function) also you have not even called the woods function and you should define the house function at the beginning of the code.
There is probably a lot more errors, but I tried to find a few of them!
+ 1
thank you! I was moving things everywhere thought I may have indented wrong and didn't paste all just were the problem was. still learning its my first little project 2 weeks in