Ask coding questions

← Back to all posts
Bug??
DeadWither (1)

Hello everyone, I am new to Replit and a beginner to Python.

While I was doing something, this bug occured
if Armour == "yes":
a = 5

This is the error :

Traceback (most recent call last):
File "main.py", line 40, in <module>
if Armour == "yes":
NameError: name 'Armour' is not defined

Can anyone help me? I have tried hard to debug it but failed

Here is part of the code
print("Aaah, I hear a monster's growl")
sword = input("Should we make a sword? Yes or No?: ")
#This is the basic part, mob part:
if sword == "yes" :
print("Good choice")
else :
print("Bad choice")

gapple = input("Should we eat the apple? Yes or No?: ")
if gapple == "yes" :
print("Good choice")
else :
print("Bad choice")

if Armour == "yes": <---
a = 5

if sword == "yes" :
b = 2

if gapple == "yes" :
c = 6

Comments
hotnewtop
FloCal35 (668)

Can you link the repl

DeadWither (1)

@FloCal35 I don't know how to so here is the code.

print("Hello Warrior !")
x = input("What is your name? : ")
print("Hello " + x)
print ("Let us have an adventure " + x)
print ("Let us walk! ")
print (" ")
print (" ")
print (" ")
print ("Oh, two ways! Which way should we go?")
y = input("Which way, first or second?: ")
if y == "first" :
print ("OMG! Diamonds! Woah!")
Armour = input("Should we make armour?, yes or no?: ")
if Armour == "yes" :
print("That is protection!")
else :
print("A loss! No protection")
else :
print ("It is a old lady!")
help = input("Should we help, yes or no?: ")
if help == "yes" :
print("The lady thanks and gives us a Golden Apple!")
else :
print("She curses you! Guess she is a witch. You Lose")

print("Aaah, I hear a monster's growl")
sword = input("Should we make a sword? Yes or No?: ")
#This is the basic part, mob part:
if sword == "yes" :
print("Good choice")
else :
print("Bad choice")

gapple = input("Should we eat the apple? Yes or No?: ")
if gapple == "yes" :
print("Good choice")
else :
print("Bad choice")

if Armour == "yes":
a = 5

if sword == "yes" :
b = 2

if gapple == "yes" :
c = 6

Power = (a + b + c)
mPower = randint(1,8)

FloCal35 (668)

As long as your indenting is fine it should work @DeadWither

FloCal35 (668)

If that doesn't work @DeadWither, invite me to the repl by using the invite button in the top right corner when you are in the workspace (coding area)

DeadWither (1)

@FloCal35 Done, if can only help me with that and tell me at the end

DeadWither (1)

I fixed it guys!

BruceLi2 (1)

did you define "Armor"?
you probably didn't add
Armor = input("stuff")