Hey!
I was trying to make an text adventure game and I can’t figure out why it doesn’t work, and how to fix it?
Here is my code
player = input("Name: ")
Help = “NO CAPS l=look n=north s=south e=east w=west take (item) l (item) use (item)”
sect1 = [“l”, “n”, “s”, “l door”]
sect2 = [“l”, “e”, “s”, “l shelf”]
sect3 = [“l”, “n”, “s”, “e”, “w”, “l shovel”, “l flower”, “l gate”, “l streets”, “take shovel”]
dis1 = “There is an door facing your north, behind you is an small garden”
dis2 = “Fortunately the door isn’t locked, you opened it. Facing north is a shelf, go south if you want to exit this building, you can go east.”
dis3 = “You are in a small garden, you can see some flowers. There is a shovel beside you. You can go north. Continue south out of the wooden gate to enter the streets, east to proceed further into the garden. You can go west.”
Csect = sect1
print(“Hello “+player+”!”)
print(“Welcome to the land of Adventures!”)
print(" “)
print(“Type Help if you are stuck.”)
print(” “)
print(”-Home-")
print(’’)
while Csect == sect1:
Ans = input("/")
if Ans == "help":
print(Help)
elif Ans in sect1:
if Ans == "l" or "look":
print(dis1)
elif Ans == "n":
Csect = sect2
print(dis2)
else:
Csect = sect3
print(dis3)
else:
print("Sorry, I don't recognize this command.")
pass
This is what happens when I run it. Everything else works fine.
Name: Python
Hello Python!
Welcome to the land of Adventures!
Type Help if you are stuck.
-Home-
/n
There is an door facing your north, behind you is an small garden
/s
There is an door facing your north, behind you is an small garden
/l
There is an door facing your north, behind you is an small garden
/
I am using PyCharm CE