I am teaching myself python in my spare time. I've only been at it for a couple days so for practice I've been messing around with various raw_input lines. Currently I am trying to make a short text-venture for a friend to try out. I have hit a block, part of it asks the user if they want to enter a village. If they choose to enter, everything works just fine, but if they choose not to, I need it to jump down past all of the dialogue and inputs that happen while inside the village. How do I make it jump down to an input further down the page?
it's very basic but here:
name = raw_input("What is your name adventurer? ")
where = raw_input("You are in a magical forest, you can go North or East, which
way do you go?")
if where.lower() == "north":
troll = raw_input("You encounter a troll, what do you do? Attack or flee? ")
else:
print("You encounter a dragon, you are dead, GAME OVER")
if troll.lower() == "attack":
print ("You have no weapon, that was a bad choice, you are dead, GAME OVER")
else:
flee = raw_input("You flee further North, you encounter a village, do you
enter or continue? ")
if flee.lower() == "enter":
army = raw_input("As you enter the village, a knight hands you a sword,
assuming you are there to join the army. Join him or leave the village? ")
else:
print ("You ignore the village and continue down the road.") #jump from here
if army.lower() == "join":
print ("You head off to war and are killed almost instantly because you are an
untrained fool")
else:
print ("You are kicked out of the village")
dark = raw_input("It is getting dark, do you continue or seek shelter") #to here
if dark.lower() == "continue":
print ("You are attacked by vampires and killed, GAME OVER")
else:
caves = raw_input("You find two caves, do you pick cave one which is pitch
black, or two which has light coming from it? ")
if caves.lower() == "one":
print ("You enter the cave, light a small fire, and sleep for the night.")
else:
print ("You enter the cave, there are bandits inside, you are murdered, GAME OVER")
I want to jump down to dark after the first bold line. If anything else is spotted that could be fixed or made better, please do speak up. All criticism is welcome.
change this block:
if flee.lower() == "enter":
army = raw_input("As you enter the village, a knight hands you a sword,
assuming you are there to join the army. Join him or leave the village? ")
else:
print ("You ignore the village and continue down the road.") #jump from here
if army.lower() == "join":
print ("You head off to war and are killed almost instantly because you are an
untrained fool")
else:
print ("You are kicked out of the village")
dark = raw_input("It is getting dark, do you continue or seek shelter")
into this block:
if flee.lower() == "enter":
army = raw_input("As you enter the village, a knight hands you a sword,
assuming you are there to join the army. Join him or leave the village? ")
if army.lower() == "join":
print ("You head off to war and are killed almost instantly because you are an
untrained fool")
else:
print ("You are kicked out of the village")
else:
print ("You ignore the village and continue down the road.")
dark = raw_input("It is getting dark, do you continue or seek shelter")
This moves the army input to inside of the enter block so that it will only execute if it goes inside that statement.
A few notes:
you probably want to put this all inside a main() function and call return whenever you die so that it wont continue. Another choice, if you dont want to use a function, is to put everything inside a try block and call raise if you die, then handle death with your except block. You say you are a beginner so you might not have learned this stuff yet but it's definitely something to look into
Related
So I am working on a coding project as I learn python. It is a relatively simple Choose Your Own Adventure game. I thought I had everything laid out properly, but when the user chooses "swim" for var choice2, it should give the game over message and terminate. However, when I run it and choose "swim" for choice2, it gives the Game Over message, but then moves on to choice11 input. I cannot for the life of me figure out what I am doing wrong. Code below:
print("Welcome to Treasure Island.")
print("Your mission is to find the treasure.")
choice1 = input("You\'re at a crossroad. There are three paths here. Do you want to go west, east, or south?").lower()
if choice1 == "west":
choice2 = input("You have entered a forest clearing, with a lake in the middle. Do you wait for the ferry, "
"swim across, or go back east?").lower()
if choice2 == "wait":
choice3 = input("You board the ferry and it takes you across the lake. "
"You see a house. Do you enter or return across the lake?").lower()
if choice3 == "enter":
print("It is dark inside the house. Suddenly you hear a growl as the light flares. "
"You are eaten by a grue. Game Over.")
else:
input(choice2)
elif choice2 == "swim":
print("You attempt to swim across, but suddenly you are attacked by a lake monster. Game Over.")
elif choice2 == "east":
input(choice1)
if choice1 == "east":
print("You come to a dead end in the forest. You are struck by several arrows from nowhere. Game Over.")
else:
choice11 = input("You move down the path and come to a fork in the road. Do you continue south or go east?").lower()
if choice11 == "south":
print("You come upon a treasure chest. When you open it, it is a mimic, with sharp nasty teeth. Game Over.")
else:
print("You come upon a veritable treasure hoard! You win!")
I suspect that this:
if choice1 == "east":
should be this:
elif choice1 == "east":
What's happening in the current code is that the entire first if choice1 == "west" block is standalone. So after the "choice2" logic completes, that whole if block exits. The code then moves on to the next if block, which is if choice1 == "east". That condition is false, so control enters the else block.
By making the second top-level if an elif you put all three of those top-level blocks into the same overall conditional evaluation.
print("Welcome to Treasure Island.")
print("Your mission is to find the treasure.")
choice1 = input("You\'re at a crossroad. There are three paths here. Do you want to go west, east, or south?").lower()
if choice1 == "west":
choice2 = input("You have entered a forest clearing, with a lake in the middle. Do you wait for the ferry, "
"swim across, or go back east?").lower()
if choice2 == "wait":
choice3 = input("You board the ferry and it takes you across the lake. "
"You see a house. Do you enter or return across the lake?").lower()
if choice3 == "enter":
print("It is dark inside the house. Suddenly you hear a growl as the light flares. "
"You are eaten by a grue. Game Over.")
else:
input(choice2)
elif choice2 == "swim":
print("You attempt to swim across, but suddenly you are attacked by a lake monster. Game Over.")
elif choice2 == "east":
input(choice1)
elif choice1 == "east":
print("You come to a dead end in the forest. You are struck by several arrows from nowhere. Game Over.")
else:
choice11 = input("You move down the path and come to a fork in the road. Do you continue south or go east?").lower()
if choice11 == "south":
print("You come upon a treasure chest. When you open it, it is a mimic, with sharp nasty teeth. Game Over.")
else:
print("You come upon a veritable treasure hoard! You win!")
You are mostly correct. In order to end the program, you need to either use exit() which will prompt the user for closing the program, or return 0 with a function. This will end the program automatically by returning False. Here's how you can do that:
def adventure():
print("Welcome to Treasure Island.")
print("Your mission is to find the treasure.")
choice1 = input("You\'re at a crossroad. There are three paths here. Do you want to go west, east, or south?").lower()
if choice1 == "west":
choice2 = input("You have entered a forest clearing, with a lake in the middle. Do you wait for the ferry, "
"swim across, or go back east?").lower()
if choice2 == "wait":
choice3 = input("You board the ferry and it takes you across the lake. "
"You see a house. Do you enter or return across the lake?").lower()
if choice3 == "enter":
print("It is dark inside the house. Suddenly you hear a growl as the light flares. "
"You are eaten by a grue. Game Over.")
return 0 # Here you need to use it
else:
input(choice2)
elif choice2 == "swim":
print("You attempt to swim across, but suddenly you are attacked by a lake monster. Game Over.")
return 0 # Here you need to use it
elif choice2 == "east":
input(choice1)
elif choice1 == "east": # Also, this should be an elif as you already have an if statement i.e. if choice1 == "west"
print("You come to a dead end in the forest. You are struck by several arrows from nowhere. Game Over.")
return 0 # Here you need to use it
else:
choice11 = input("You move down the path and come to a fork in the road. Do you continue south or go east?").lower()
if choice11 == "south":
print("You come upon a treasure chest. When you open it, it is a mimic, with sharp nasty teeth. Game Over.")
return 0 # Here you need to use it
else:
print("You come upon a veritable treasure hoard! You win!")
adventure()
Output:
Welcome to Treasure Island.
Your mission is to find the treasure.
You're at a crossroad. There are three paths here. Do you want to go west, east, or south?west
You have entered a forest clearing, with a lake in the middle. Do you wait for the ferry, swim across, or go back east?swim
You attempt to swim across, but suddenly you are attacked by a lake monster. Game Over.
You are doing most of the things right but one thing that bothers me is that you are using input(choice1) or input(choice2) in some lines. I guess what you wanted was to take this input again, right? Think about it again because this will simply not work that way.
Edit: Looks like my main problem was, for whatever reason, having the boolean operator "or" in my choices would default the user to playing both choices, or the affirmative one instead of the negative one. If anyone can explain why, I would greatly appreciate it.
I am a novice to Python 3, that is probably obvious, so hopefully this is a simple fix. I really want to complete this game as it is one of the only projects I find as a "fun" way to learn that constantly keeps me focused (and frustrated). I would also eventually like to add more complicated features like a user inventory. I have been following some function-based youtube guides and essentially some paths in my game work (north>>west>>fight) while some do not (north>>east>>no). In the latter case, my program chooses "Y" every time on the third choice the player makes, even if the player writes "N". The issue pops up several other times in this chunk of code. Here, I'll show you(and if you see anything else fundamentally wrong with my code, let me know):
#Author: Joseph C 2021
# Cyoa (Kyoa) is a text-based fantasy game set in the realm of Kyoa. The Traveller awakens empty-handed and
# without any inkling of memory about who s/he is or what this strange medieval motor-punk world has to offer...
import random
import time
def playagain():
answer = input("Do you want to play again? Y or N")
if answer == "Y":
print("OK.")
chapter1()
elif answer == "N":
print("Goodbye.")
def Intro():
print("Hey there...")
time.sleep(.5)
print("Hello?!")
time.sleep(1.5)
print("WAKE UP!")
time.sleep(1)
print("You awaken under a bodhi tree, to the annoying chirp of your Lilliputian fairy ally, Pyxys. She soon figures")
print("that you've lost your memory due to the encounter up north, and respawned in the middle of a hilly field.")
print("As a blank slate and denizen of the uncharted realm of Kyoa, you and Pyxys decide to explore once more.")
def chapter1():
choice = input("Do you choose to go north, south, east, or west? \n")
if choice == "north":
print("You move forward in this direction. You witness a murder of winged orca whales in the blue, star"
"covered yet daylit sky.")
chapter1north()
if choice == "east":
chapter1east()
if choice == "south":
print("You walk a lot, pass by a lake with a distant background mountain range, and finally")
print("come across an abandoned town. You loot a house and find a sack of gold! But suddenly,")
print("a cohort of Vector Vipers and Glue Goblins gang up on you! You have died.")
playagain()
if choice == "west":
print("You walk a lonely, boring path that twists and wanes but ultimately points west.")
print("Before you know it, you stand before a tall evergreen forest, densely packed with")
print("rocks and trees.")
chapter2SF()
def chapter1north():
time.sleep(.5)
print("You continue walking north...")
time.sleep(1)
print("You come across a dense carniferous forest on the horizon to the east, and more spacious hillsides to"
"the west.")
choice = input("Will you go west toward the hilly plains, or east toward the dense woods? \n")
if choice == "west":
print("As you tread upon the hills towards the northwest, you encounter a spinfoam slime!")
decision = input("Fight or flee?")
if decision == "fight":
print("You stomp on the paltry slime multiple times until it dissociates, bubbling into gas!"
"Congratulations! You gained 2 XP!")
chapter2()
if decision == "flee":
print("You evade the paltry slime, yet you hear something from a distance...")
time.sleep(1)
print("The spinfoam slime sends a torrent of electricity towards you, burning you to a crisp!"
"You have died.")
playagain()
if choice == "east":
print("You approach the thick forest, which you find is gated by barbed wire.")
time.sleep(1) #at this point the code starts to bug. Maybe I need to make this in a new function
InsectForestEntrance()
def InsectForestEntrance():
decision2 = input("You decide to walk amid the perimeter of the barbed forest, heading in the"
"east and southeast directions...You manage to find an entrance."
" Will you enter? (Y or N)\n")
if decision2 == "yes" or "Y":
print("You enter the Insect Forest...")
time.sleep(1)
chapter1insectforest()
elif decision2 == "no" or "N":
print("You decide to travel south, as the forest expands throughout the entirety of the north.")
chapter1east()
def chapter1insectforest():
print("Immediately, the forest forks into two paths: one going northbound, the other southeastern.")
decision2a = input("Which one will you take? north or southeast?")
if decision2a == "north":
pass
if decision2a == "southeast":
print("You go")
def chapter2():
pass
def chapter3():
pass
def chapter4():
pass
Intro()
chapter1()
I started learning python recently and I'm learning it from the book "Learn python the hard way". As a task I'm supposed to create my own text game. But I'm stuck with this one issue.
Is there a way for me to make it so when I type in "I don't open the door" in the input that it doesn't run the if-statement? Also I want to make all the results lowercase just to prevent any possible errors due to upper and lowercase usage.
def hall():
print("You entered the gate and you are in a long hall.")
print("You see a wooden door to your right side.")
print("What do you do?")
open_door = str.lower("open")
next_move = str.lower(input("> "))
words = next_move.split()
if open_door in words:
print("You open the door and enter a dark room.")
print("Sentence 2")
print("Sentence 3")
dead("Sentence 4")
else:
continue_forward()
I want it to run if-statement when I type in "I open the door" but not when I type in "I don't open the door.
I've tried adding new variable such as do_not_open and using it as elif in this statement but it mixes it and it doesn't work.
def hall():
print("You entered the gate and you are in a long hall.")
print("You see a wooden door to your right side.")
print("What do you do?")
open_door = str.lower("open")
do_not_open = str.lower("don't")
do_not_open2 = str.lower("do not")
do_not_open3 = str.lower("dont")
next_move = str.lower(input("> "))
words = next_move.split()
if open_door in words:
print("You open the door and enter a dark room.")
print("Sentence 2.")
print("Sentence 3")
dead("Sentence 4")
elif do_not_open or do_not_open2 or do_not_open3 in words:
print("You continue through the hall.")
hall2()
else:
continue_forward()
Even here when I type in "I open the door" it works, but when I type in "I don't open the door" it doesn't work and it just runs the if open_door in words... And only time it works is when I specifically type in the values such as "don't" or "do not".
Here is the example:
PS C:\Users\...> python ex35v2.py
You are in a dark forest.
You see a dim light in front of you. Do you go forward?
> yes
You approach the tall metal gate.
There is a button on the side of it.
Do you press it?
> yes
The gate opens. Do you go in?
> yes
You go inside and the gate closes.
You entered the gate and you are in a long hall.
You see a wooden door to your right side.
What do you do?
> I open the door
You open the door and enter a dark room.
Sentence 2
Sentence 3
Sentence 4 Better luck next time!
PS C:\Users\...> python ex35v2.py
You are in a dark forest.
You see a dim light in front of you. Do you go forward?
> yes
You approach the tall metal gate.
There is a button on the side of it.
Do you press it?
> yes
The gate opens. Do you go in?
> yes
You go inside and the gate closes.
You entered the gate and you are in a long hall.
You see a wooden door to your right side.
What do you do?
> I don't open the door
You open the door and enter a dark room.
Sentence 2
Sentence 3
Sentence 4 Better luck next time!
PS C:\Users\...> python ex35v2.py
You are in a dark forest.
You see a dim light in front of you. Do you go forward?
> Yes
You approach the tall metal gate.
There is a button on the side of it.
Do you press it?
> yes
The gate opens. Do you go in?
> YES
You go inside and the gate closes.
You entered the gate and you are in a long hall.
You see a wooden door to your right side.
What do you do?
> Don't
You continue through the hall.
Hall sentence 2
Hall sentence 3
Hall sentence 4
Hall sentence 5
> clear
Hall sentence 6
Hall sentence 7
Hall sentence 8
> clear
Hall sentence 9
Hall sentence 10 Better luck next time!
PS C:\Users\...> python ex35v2.py
You are in a dark forest.
You see a dim light in front of you. Do you go forward?
> yes
You approach the tall metal gate.
There is a button on the side of it.
Do you press it?
> YES
The gate opens. Do you go in?
> YEs
You go inside and the gate closes.
You entered the gate and you are in a long hall.
You see a wooden door to your right side.
What do you do?
> Do NOT
You continue through the hall.
Hall sentence 2
Hall sentence 3
Hall sentence 4
Hall sentence 5
.
.
.
If there is a possible way to make this actually work, please let me know.
As I'm quite new I'm not sure if this is the best way to do it but I ran the code myself and it seems to work. I've actually done the same exercise before but it was a lot more simple.
def hall():
print("You entered the gate and you are in a long hall.")
print("You see a wooden door to your right side.")
print("What do you do?")
open_door = "open"
do_not_open = "don\'t"
do_not_open2 = "do not"
do_not_open3 = "dont"
do_not_open4 = "not"
next_move = input("> ").lower()
words = next_move.split()
if open_door in words:
if do_not_open not in words:
print("You open the door and enter a dark room.")
print("Sentence 2.")
print("Sentence 3.")
dead("Sentence 4.")
elif do_not_open in words:
print("You continue through the hall.")
continue_forward()
elif do_not_open2 in words:
print("You continue through the hall.")
continue_forward()
elif do_not_open3 in words:
print("You continue through the hall.")
continue_forward()
elif do_not_open4 in words:
print("You continue through the hall.")
continue_forward()
elif do_not_open in words:
print("You continue through the hall.")
continue_forward()
elif do_not_open2 in words:
print("You continue through the hall.")
continue_forward()
elif do_not_open3 in words:
print("You continue through the hall.")
continue_forward()
elif do_not_open4 in words:
print("You continue through the hall.")
continue_forward()
else:
continue_forward()
As I've said, I'm sure there is a cleaner and better way to do it, but this worked for me.
There is a logical error in your elif statement.
if var1 or var2 or var3 in valid_vars:
print("valid")
this statement will output valid till you provide any value (other than 0 or None or empty list, string, dict, or set ) to var1 or var2 OR if any of value of valid_vars is matched with var3.
To understand better, your statement is read like this
elif (do_not_open) or (do_not_open2) or (do_not_open3 in words):
print("You continue through the hall.")
hall2()
You should make a list of valid commands
for example
open_word = ['yes', 'open']
do_not_open = ['don\'t', 'do not', 'dont', 'not']
word = input('> ')
then make condional statements like this. (replace pass with your desired functionality)
if words.lower() in open_word:
pass
elif words.lower() in do_not_open:
pass
else:
pass
I'm trying to make a simple text adventure game with three choices. But I can't seem to figure out why this isn't working.
This is the code I have been working on:
#Text based medieval adventure game
#Imported libraries are required
import random
import time
def displayWelcome():
print ("\nText adventure game\n")
print ("Welcome to the medieval adventure game!")
print ("You will have many choices through out this game")
print ("Be sure to pick the right one")
print (" Good Luck! ")
answer = askYesNo("Would you like help with this program? (Y/N): ")
if answer == "Y":
helpForUser()
time.sleep(3)
def askYesNo (question):
# This function will ask you a yes or no question and will keep asking until one is chosen.
# The following function is used to erase the variable response of any values
response = None
while response not in ("Y", "N"):
response = input (question).upper()
return response
def helpForUser():
#This function will show the user some helpful advice if they desire it
print ("\n+++++++++++++++++++++++++++++++++++++++ Help +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
print ("This game is a adventure text based game set in the medieval times")
print ("You will be asked multiple questions with a yes or no response")
print ("you must answer the questions with the answers supplied to you suches as yes or no")
print ("If you don't answer the q uestion with the given answers it will be repeated untill a valid response occurs")
print ("The program can end when you choose")
print ("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
def displayIntro():
#Displays intro to game
print ("\n It's been a rough day in the wild and you despratly need shelter")
print ("There is currently a war going on and nowhere is safe")
print ("But you intend to find somwhere with food and a bed but it wont be easy...")
print ()
def choosePath(lower,middle,upper):
#This functions allows you to choose between multiple options
path = 0
while path < lower or path > upper:
number = input("What path will you take(" + str(lower) + " - " + str(upper) + ")?: ")
if number.isdigit():
path = int (number)
else:
path = 0
return path
def followPath(chosenPath):
print ("you head down a long road\n")
time.sleep(3)
print ("You come across an abandoned campsite and decide to stay there for the night")
time.sleep(3)
print("You wake up to a sudden sound of voices and begin to realise that this campsite wasn't abandoned...")
time.sleep(3)
print("You start to freak out")
time.sleep(3)
if chosenPath == 1:
print("You grab your sword out and decide to go out the tent")
print ("Four well trained knights surround you")
print ("They strike without any hesitation, you counter two knights trying to hit you from the front as two from behind stab you in the back")
print ("The knights decide to burn your body and leave nothing left of you.\n")
elif chosenPath == 2:
print("You dart out of the tent and head for the exit")
print("All the guards try and get you whilst shooting arrows")
print("Several arrows hit you leaving you injured unable to run")
print ("Suddenly a man with a giant axe appears before you and slices you head off in a clean swoop\n")
else chosenPath == 3:
print("You keep calm and decide to sneak past all the guards")
print ("You're close to the exit when suddenly a guard notices you")
print("He's about to call for back up when you dash right into his chest with your sword, leaving it in him and running out the campsite")
print("You make it to a safe forest and decide to rest\n")
displayWelcome()
playAgain = "Y"
while playAgain == "Y":
displayIntro()
choice = choosePath()
followPath(choice)
playAgain = askYesNo ("Would you like to play again?")
print ("\nBye")
Error Number one: line 63, else should be elif or get rid of the condition "chosenPath == 3:
Current state
else chosenPath == 3:
What it should look like
elif chosenPath == 3:
or
else:
The other error is that nothing ever happens on initialization of choice because you forgot to input the "lower, middle, upper" values.
When the user chooses option 4 on hall(), it should run blue(), but when I try to run it I get an error saying that blue() is not defined. How do I fix this?
import time
import sys
name = input ("Name: ")
print ("Hello", (name), ", and welcome to my game that i made to learn python.")
print ("How to play the game, just type the number its not that hard.")
time.sleep(5)
def intro():
print ("You are in a room, to the south there is a torch on the wall and to the north there is a door.")
time.sleep(5)
print ("Your options are: ")
time.sleep(3)
print ("1. Do nothing")
print ("2. Go south and pick up the torch")
print ("3. Go north, open and go through the door")
print ("4. You decide to build an orphanage in the room, makes sense.")
choice = input(">>> ")
if choice == "1":
print("You decide to curl into a ball and go to sleep, you never wake up again. --GAME OVER--")
print("I guess you could try again if you must.")
time.sleep(5)
intro()
elif choice == "2":
print("You walk southwards towards the wall, grab the torch off the wall and hold it in your hands.")
print("You walk over towards the door and open it")
time.sleep(5)
elif choice == "3":
print("You walk over towards the door and open it, on the other side there is a dark corridor, you step forward and the door closes behind you. You get surrounded in darkness and die. --GAME OVER--")
print("I guess you could try again if you must.")
time.sleep(5)
intro()
elif choice == "4":
print("You can't build an orphanage in a room with nothing there idiot, you wasted your whole life attempting. --GAME OVER--")
print("I guess you could try again if you must.")
time.sleep(5)
intro()
else:
print("Type the correct number idiot")
intro()
intro()
def hall():
print ("As you open the door a strong gust of cold air comes through making the torch flicker")
time.sleep(3)
print ("You continue up the corridor with the torch illuminating your surroundings, you feel like your being watched")
time.sleep(3)
print ("You keep walking for what seems like hours and you finally come across a part where the corridor splits off into 3 different ones")
print ("What do you do?")
print ("1. Go north.")
print ("2. Go east.")
print ("3. Go back the way you came.")
print ("4. Go west.")
time.sleep(5)
hall()
choice = input(">>> ")
if choice == "1":
print("You head north but as soon as you do the ground under you crumbles and you fall. And die. --GAME OVER--")
print("I guess you could try again if you must.")
time.sleep(5)
hall()
elif choice == "2":
print("You go down the east corridor and get a glimpse of a dark red light before it disappears.")
print("You continue to walk")
time.sleep(5)
red()
elif choice == "3":
print("Well done, you just went back to the place you wanted to get out from, your legs are tired and your torch has gone out. idiot. --GAME OVER--")
print("I guess you could try again if you must.")
time.sleep(5)
hall()
elif choice == "4":
print("You go down the west corridor and get a glimpse of a dark blue light before it disappears.")
print("You continue to walk")
time.sleep(5)
blue()
else:
print("Type the correct number idiot")
time.sleep(5)
hall()
def red1():
print ("As you continue to walk down the corridor the air around you seems to head up more and more.")
time.sleep(3)
print ("You come around a little podium and on it is a piece of paper with the numbers 264 894 written on it")
time.sleep(3)
print ("You go to pick it up but it crumbles into dust and under the dust are the words blue carved into the podium")
time.sleep(3)
print ("you continue walking")
time.sleep(3)
print ("After a while you come across a shiny iron door with a keypad by the side on the keypad it spells the words red on it.")
time.sleep(3)
print ("You attempt to enter the correct code.")
red1()
code1 = input(">>> ")
if code1 == "362 682":
print ("The door slides open without making a noise, you step into the door and continue walking")
else:
print ("Incorrect code. Hint:RED")
print ("restarting...")
time.sleep(10)
intro()
def blue1():
print ("As you continue to walk down the corridor the air around you seems to get colder and colder more and more.")
time.sleep(3)
print ("You come around a little podium and on it is a piece of paper with the numbers 362 682 written on it")
time.sleep(3)
print ("You go to pick it up but it crumbles into dust and under the dust are the words red carved into the podium")
time.sleep(3)
print ("you continue walking")
time.sleep(3)
print ("After a while you come across a rusty iron door with a keypad by the side on the keypad it spells the words red on it.")
time.sleep(3)
print ("You attempt to enter the correct code.")
blue1()
code2 = input(">>> ")
if code2 == "264 894":
print ("The door slides open without making a noise, you step into the door and continue walking")
else:
print ("Incorrect code. Hint:BLUE")
print ("restarting...")
time.sleep(10)
intro()
nice story btw). anyway to the problem.
you call function blue() that is not defined in your code - there is no such function ). if you meant to call blue1() you will get an error and that's because
you first need to declare the function before using it
for example:
1.this will not work:
blue()
def blue(): ...
2. this will work:
def blue(): ...
blue()
any way for good practice its good to maintain a simple code structure, all functions above and the main is the last one that calls other function.
The reason you're getting an error is because there indeed is no function called blue() defined. It's blue1() in your code. I strongly suggest investing in a linter.