else command not running correctly? (Python 3 Beginner) - python

I'm working on a combo menu for my first Python program. I've gotten everything to work properly up to this point. I want the program to exit if the user's input isn't equal to the accepted answers. I've tried a few different methods to get this working, but it still just runs like I answered "Yes" or "yes". Any help? Thanks a ton.
Here is my code:
def p(): #Prints new line quiokly
print()
def error(): #Restarts the main
question = input("You have entered an invalid option. Would you like to try your order again? \n")
if question in ("Yes","yes","yes"):
main()
else:
exit
def main(): #Main block of code
cost = 0 #total cost variable
if cost == 0:
print("What type of sandwhich would you like? Refer to the cost and type of sandwhich below.")
p()
print("Chicken Sandwhich = $5.25")
p()
print("Tofu Sandwhich = $5.75")
p()
print("Beef Sandwhich = $6.25") #initial questions
x = input()
if x == ("Beef") or x == ("beef"):
cost += 6.25
print("You have selected Beef. Your total is so far is $6.25.")
elif x == ("Chicken") or x == ("chicken"):
cost += 5.25
print("You have selected Chicken. Your total is so far is $5.25.")
elif x == ("Tofu") or x == ("tofu"):
cost += 5.75
print("You have selected Tofu. Your total is so far is $5.75.")
if x not in ("beef" , "Beef" , "Tofu" , "tofu" , "chicken" , "Chicken"): #checks for valid resposne
error()
print("Would you like to add a drink to your meal?")
p()
yzz = input()
if yzz == ("Yes") or ("yes"):
p()
print("Okay, would you like small, medium, or large? Refer to the prices below.")
print(cost)
p()
print("Small - $1.00")
p()
print("Medium - $1.75")
p()
print("Large - $2.25")
p()
yzzz = input()
if yzzz == ("Small") or yzzz == ("small"):
cost += 1
print("You have selected a small drink. Your total is so far is " + "$%.2f" %cost + ".")
elif yzzz == ("Medium") or yzzz == ("medium"):
cost += 1.75
print("You have selected a medium drink. Your total is so far is " + "$%.2f" %cost + ".")
elif yzzz == ("Large") or yzzz == ("large"):
cost += 2.25
print("You have selected a large drink. Your total is so far is " + "$%.2f" %cost + ".")
if yzzz not in ("small" , "Small" , "Medium" , "medium" , "large" , "Large"): #checks for valid response
error()
elif yzz not in ("yes","Yes"):
exit
#Main code starts here!
main()

The indent for the line elif yzz not in ("yes","Yes"): is wrong, you need to indent it one more time.
Also the expression if yzz == ('Yes') or ('yes') will always evaluate to True because the or expects a boolean to either side and ('yes') evaluates to True.
instead write if yzz in ['Yes', 'yes']

Related

Can someone please explain to me why the 'health' var is not updated when calling the updateGame() func

Been looking online for some answers, however it's still unclear to me why the 'health' var is not updated when calling the getDamage() func
I'm on my first few miles learning python
health = 200.0
maxHealth = 200
healthDashes = 20
dashConvert = int(maxHealth/healthDashes)
currentDashes = int(health/dashConvert)
remainingHealth = healthDashes - currentDashes
healthDisplay = '-' * currentDashes
remainingDisplay = ' ' * remainingHealth
percent = str(int((health/maxHealth)*100)) + "%"
gameOver = False
def updateGame():
print(chr(27) + "[2J")
print (30 * '-')
print("")
print(" |" + healthDisplay + remainingDisplay + "|")
print(" health " + percent)
print ("")
print (30 * '-')
print("")
def getDamage():
global health
health = 10
while gameOver == False:
answer = raw_input("> ").lower()
if answer == "help":
print("")
print(" you can use the following commands: h, i, q, d")
print("")
elif answer == "q":
print("\n")
print("Game Over")
print("")
break
elif answer == "h":
updateGame()
elif answer == "d":
getDamage()
else:
print(""" not a valid command, see "help" """)
Is there anything I can do to properly update the "health" var and disply a reduced health the next time I call the getDamage() func?
Basically what I'm trying to achieve is a text-based game to run in a while loop and have different functions to update a primary function (updateGame) that display relevant info about the player's state like health, inventory items.
The logic I'm trying to implement is:
have getDamage() reduce the health var and then display the newly change variable with updateGame()
Many thanks
health will change to 10 when you call getDamage() but healthDisplay, remainingDisplay and percent are set at the first of script and won't change everytime that healt global variable is changed. so you must change them in updateGame() function everytime it's called. Also i guess health = 10 must change to health -= 10!
health = 200.0
maxHealth = 200
healthDashes = 20
gameOver = False
def updateGame():
dashConvert = int(maxHealth/healthDashes)
currentDashes = int(health/dashConvert)
remainingHealth = healthDashes - currentDashes
healthDisplay = '-' * currentDashes
remainingDisplay = ' ' * remainingHealth
percent = str(int((health/maxHealth)*100)) + "%"
print(chr(27) + "[2J")
print (30 * '-')
print("")
print(" |" + healthDisplay + remainingDisplay + "|")
print(" health " + percent)
print ("")
print (30 * '-')
print("")
def getDamage():
global health
health -= 10
while gameOver == False:
answer = input("> ").lower()
if answer == "help":
print("")
print(" you can use the following commands: h, i, q, d")
print("")
elif answer == "q":
print("\n")
print("Game Over")
print("")
break
elif answer == "h":
updateGame()
elif answer == "d":
getDamage()
else:
print(""" not a valid command, see "help" """)
Inside the updateGame function, you never make reference to the global variable health. If you want health to change inside the function, you will need to access it.
This means you should have something like:
def updateGame():
global health
health = updatedHEALTH
...
Then it should change each time you call the function

'int' object not subscriptable error

while 1 == 1:
import csv
from time import sleep
import sys
bill = 0
with open('list2.txt') as csvfile:
readCSV = csv.reader(csvfile, delimiter = ",")
GTINs = []
products = []
prices = []
for row in readCSV:
GTIN = row[0]
product = str(row[1])
price = float(row[2])
GTINs.append(GTIN)
products.append(product)
prices.append(price)
x = 1
print("Welcome to the GTIN shop!")
while x == 1:
try:
sleep(1)
print("Please input the 8 digit GTIN code")
sleep(0.5)
GTIN0 = GTIN[0]
GTIN1 = GTIN[1]
GTIN2 = GTIN[2]
GTIN3 = GTIN[3]
GTINx = input("--> ")
The error brought up here is that on the lines GTIN0 = GTIN[0] etc, the 'int' object not subscriptable, I can't work out how to fix it, it used to work before.
For reference, here is "list2.txt".
45112454,Milk,1.29
55555555,Bread,0.49
87595376,Milkshake,1.99
The next error comes up here (continuing from last segment):
GTINx = input("--> ")
if GTINx == GTIN0:
product1 = products[0]
price1 = prices[0]
x = 2
elif GTINx == GTIN1:
product1 = products[1]
price1 = prices[1]
x = 2
elif GTINx == GTIN2:
product1 = products[2]
price1 = prices[2]
x = 2
elif GTINx == GTIN3: (this one is just here for if another one is added)
product1 = products[3]
price1 = prices[3]
x = 2
else:
print("Have another go")
except:
print("ERROR - Try Again")
To retrieve milk, the code is 7. For bread the code is 8, and for milkshake, the code is 9. I have no idea where python got these numbers from...
while x == 3:
try:
sleep(1)
print("So you would like", number, product1, "?")
sleep(0.5)
confirmation = input("Please enter \"YES\" or \"NO\": --> ")
if confirmation == ("YES") or ("Yes") or ("yes"):
x = 4
elif confirmation == ("NO") or ("No") or ("no"):
x = 1
else:
sleep(0.5)
print("Have another go")
except:
print("ERROR - Try Again")
So, this was supposed to end that loop, and send them back to the start if they said no (relooped via while 1 == 1:) but, it acts as if they said yes, no matter what was typed.
Next is a similar issue...
while x == 4:
try:
cost = price1 * number
bill = bill + cost
print("The cost is", cost)
sleep(5)
print("Would you like to purchase anything else?")
sleep(0.5)
anythingelse = input("Please enter \"YES\" or \"NO\": --> ")
sleep(1)
if anythingelse == ("YES") or ("Yes") or ("yes"):
x = 1
elif anythingelse == ("NO") or ("No") or ("no"):
x = 5
else:
sleep(0.5)
print("Have another go")
except:
print("ERROR - Try Again")
Again, it answers yes, no matter what is inputted.
Sorry for the spam, thanks for any help that I get.
For your loops if confirmation == ("YES") or ("Yes") or ("yes"):
That's never going to work in Python because you are basically asking if confirmation is equal to "YES" or if ("Yes") or if ("yes") ; and if ("Yes") is true because it's valid and not None or 0 or empty. You want:
if confirmation == ("YES") or confirmation == ("Yes") or confirmation == ("yes"):
There are other ways to do your or checking but I'm just going to correct what you have.
As the comments and other answers has pointed out, a better way of checking "yes" would be:
if confirmation.lower() == "yes"
Just turn the input to lower case and check the value.
As for your first issue. GTIN0 = GTIN[0] do you mean GTIN0 = GTINs[0]. Because GTIN is an int not something "subscriptable" just like what the error is telling you.
As for your second issue with GTIN0 and what not, see if the fix fixes it for you since the GTIN0 and so on, was never set correctly. Edit your question if it's still wrong after the fixes.
Also this line
elif GTINx == GTIN3: (this one is just here for if another one is added)
is not really correct for commenting (I'm guessing your commenting, use a # in front of comment lines)
elif GTINx == GTIN3: #(this one is just here for if another one is added)
In relation with the 'if' comparison issue, I would recommend you to firstly remove the Upper format from the string and then compare. It would be then more idiomatic and also youre problem would be solved:
if anythingelse.lower() == ("yes"):
x = 1
elif anythingelse.lower() == ("no"):
x = 5
else:
sleep(0.5)
print("Have another go")

Expected an indentation block Python error

I've looked at the similar questions but all were either a description without indentation after an if statement, or a weird mixture of spaces and tabs. I have tried removing all of the tabs and using 4 spaces and also tried with all tabs, I'm just stuck now. I've tried retyping the whole thing but I must be missing something. Any help would be greatly appreciated
EDIT: Posting the whole thing as people are getting confused about the functions which I didn't post
from sys import exit
class player:
str = 0
wep_dam = 0
dam = str + wep_dam
cha = 0
sne = 0
arm = 0
max_life = 10
points_remaining = 0
cave_save = False
cave_fork_save = False
dragon_save = False
def exit_beach():
print "Walking further up the beach from water, you see a cave."
print "Above the cave hangs a warning sign, it reads:\n"
print "\"DANGER: Tresspassers will be killed and eaten\""
ans = raw_input("Ignore the warning and enter the cave?\n\n1. Enter the cave\n2. Continue walking\n\n> ")
if ans == "1":
cave()
elif ans == "2":
troll()
else:
print "Error, you didn't enter 1 or 2\n"
def shadow_figure():
print "\n\nYou approach the figure, who remains silent."
print "As you get closer you realise he has bag at his feet."
print "Mysterious figure: \"You may choose only one.\""
print "You look into the bag, and see a shiny sword on top of a large steel shield."
ans = raw_input("Do you: \n1. Take the sword \n2. Take the shield \n3. Take the whole bag and run \n4. Walk away without taking anything\n> ")
if ans == "1":
print "The sword gives you an extra 3 damage"
player.wep_dam += 3
exit_beach()
elif ans == "2":
print "The shield gives you 3 armor, but it's so heavy it reduces your sneak by 1"
player.arm += 3
player.sne -= 1
exit_beach()
elif ans == "3":
dungeon("You get about 10 feet away with the bag before bony fingers grip your throat and choke you unconscious")
elif ans == "4":
exit_beach()
else:
print "Error, please enter anumber between 1 and 4"
def beach():
print "\n\nYou wake up on a beach with no idea how you got there. \nYou see a shadowy figure close to the water."
ans = raw_input("Do you: \n1. Approach him \n2. Go the other way\n> ")
if ans == "1":
shadow_figure()
elif ans == "2":
exit_beach()
else:
print "Please enter either 1 or 2"
def dungeon(why):
print why
if not player.cave_save and not player.dragon_save and not player.cave_fork_save:
print "Unfortunately you didn't get far enough to continue from a saved point, \n would you like to restart from the beginning? (Yes/No)"
ans = raw_input("> ")
ans = ans.lower()
if ans == "yes":
reset_stats()
start()
else:
end()
elif player.cave_save and not player.dragon_save and not player.cave_fork_save:
print "Would you like to continue from the cave entrance or start over?"
print "1. Cave entrance\n2. Start over\n3. Exit game"
ans = raw_input("> ")
if ans == "1":
cave()
elif ans == "2":
reset_stats()
start()
else:
end()
elif player.cave_save and player.cave_fork_save and not player.dragon_save:
print "Would you like to continue from the cave entrance, the cave fork, or start over?"
print "1. Cave entrance\n2. Cave fork\n3. Start over\n4. Exit game"
ans = raw_input("> ")
if ans == "1":
cave()
elif ans == "2":
cave_fork()
elif ans == "2":
reset_stats()
start()
else:
end()
else:
print "Havent done this part yet"
def reset_stats():
str = 0
wep_dam = 0
dam = str + wep_dam
cha = 0
sne = 0
arm = 0
max_life = 10
points_remaining = 10
print "\n\n\n\nGame Reset\n\n\n\n"
def end():
print "Thank you for playing"
exit(0)
def start():
print "You are an adventurer, your stats are currently:"
print "Strength: %d \nCharisma: %d \n Sneak: %d" % ( player.str, player.cha, player.sne)
print "Strength determines your damage, charisma determines your chance of pursuasion, \nand sneak determines whether or not you can go get past enemies without being detected"
print "you have 10 points available to spend, to spend a point, simply type the number which corresponds\nwith the skill and hit enter"
print "\n\n1. Strength \t2. Charisma \t3. Sneak\n"
player.points_remaining = 10
while player.points_remaining > 0:
ans = raw_input("Choose a skill: ")
if ans == "1":
player.str += 1
player.points_remaining -= 1
print "Strength is now %d" % ( player.str)
print "%d points remaining\n" % ( player.points_remaining)
elif ans == "2":
player.cha += 1
player.points_remaining -= 1
print "Charisma is now %d" % ( player.cha)
print "%d points remaining\n" % ( player.points_remaining)
elif ans == "3":
player.sne += 1
player.points_remaining -= 1
print "Sneak is now %d" % ( player.sne)
print "%d points remaining\n" % (player.points_remaining)
else:
print "Error, please enter a number from 1 to 3\n"
print "Your stats are now: "
print "Strength: %d \nCharisma: %d \n Sneak: %d\n\n" % ( player.str, player.cha, player.sne)
print "Is this OK? Or would you like to restart?\n"
ans = raw_input("1. Continue \n2. Restart\n> ")
if ans == "1":
print "Game will now begin...."
beach()
elif ans == "2":
ans = raw_input("Are you sure? Yes/No\n> ")
ans = ans.lower()
if ans == "yes":
reset_stats()
start()
else:
beach()
else:
print "Error, please enter 1 or 2"
start()
Corrected code:
def shadow_figure():
print "\n\nYou approach the figure, who remains silent."
print "As you get closer you realise he has bag at his feet."
print "Mysterious figure: \"You may choose only one.\""
print "You look into the bag, and see a shiny sword on top of a large steel shield."
ans = raw_input("Do you: \n1. Take the sword \n2. Take the shield \n3. Take the whole bag and run \n4. Walk away without taking anything\n> ")
if ans == "1":
print "The sword gives you an extra 3 damage"
wep_dam += 3
exit_beach()
elif ans == "2":
print "The shield gives you 3 armor, but it's so heavy it reduces your sneak by 1"
arm += 3
sne -= 1
exit_beach()
elif ans == "3":
dungeon("You get about 10 feet away with the bag before bony fingers grip your throat and choke you unconscious") #Should dungeon() be print instead?
elif ans == "4":
exit_beach()
else:
print "Error, please enter a number between 1 and 4"
See Vaibhav Mule's answer. You were using the assignment operator on input 3 and 4, rather then the comparison operator. There might be more wrong here, but it's hard to tell without the rest of your code. Also I'm not sure what your dungeon() function does, but you probably meant print?
Please also look at elif block, where you suppose to do.
elif ans == "3": # make sure you have '==' operator here.
elif ans == "4":
The error was pointing to line 20, which in this case would be line 1.
The error was in the function exit_beach() that was being called and not actually within this function.
As soon as I added the correct indentation to function exit_beach() the error disappeared.

Python 2.7 Slot Machine if statement issue

import random
numbers = []
wheel1 = 0
wheel2 = 0
wheel3 = 0
winnings = int(0)
balance = int(50)
def generator(balance):
number1 = random.random()
number2 = random.random()
number3 = random.random()
if number1 < 0.05:
wheel1 = "Cherry"
elif number1 < 0.15:
wheel1 = "Diamond"
elif number1 < 0.30:
wheel1 = "Hearts"
elif number1 < 0.65:
wheel1 = "Spade"
elif number1 < 1:
wheel1 = "Monkey"
if number2 < 0.05:
wheel2 = "Cherry"
elif number2 < 0.15:
wheel2 = "Diamond"
elif number2 < 0.30:
wheel2 = "Hearts"
elif number2 < 0.65:
wheel2 = "Spade"
elif number2 < 1:
wheel2 = "Monkey"
if number3 < 0.05:
wheel3 = "Cherry"
elif number3 < 0.15:
wheel3 = "Diamond"
elif number3 < 0.30:
wheel3 = "Hearts"
elif number3 < 0.65:
wheel3 = "Spade"
elif number3 < 1:
wheel3 = "Monkey"
return wheel1
return wheel2
return wheel3
def win(generator,balance):
generator(balance)
if wheel1 =="Monkey"and wheel2 == "Monkey"and wheel3 == "Monkey":
print "JACKPOT!"
winnings = int(50)
balance + winnings
print 'JACKPOT!'
else:
print 'noice'
winnings = int(10)
balance + winnings
print 'noice'
return balance
print "Welcome to the International Slot Machine"
print ""
print "Balance: $",balance
print ''
spinyn = (raw_input("Would you like to spin? $5 per spin. Enter y or n:\n"))
while True:
if spinyn == "y":
break
elif spinyn == "n":
print "Final Balance: $",balance
print "Thank you for using the International Slot Machine"
raise SystemExit
else:
spinyn = raw_input('\033[31mPlease enter only y or n.\033[0m\n')
spin = (raw_input("Press enter to spin for $5:\n"))
while True:
if spin == '':
balance = balance - 5
if balance <= 0:
print ""
print "Final Balance: $",balance
print "You have run out of money, the game has now ended."
raise SystemExit
print ""
print "\033[34mResult:\033[0m"
print "\033[34m-------\033[0m"
balance = generator(balance)
print ""
print win(generator,balance)
print "New balance:$",balance
print ""
spinagain = (raw_input("Would you like to spin again? Press enter to spin again, type anything to exit.\n"))
while True:
if spinagain == "":
break
else:
print "Final Balance: $",balance
print "Thank you for using the International Slot Machine"
raise SystemExit
else:
spin = (raw_input("Please press enter to spin.\n"))
I appreciate any suggestions about the method of selecting a random symbol, but please withhold as there is only one question I have. My question is: In the win function, how do I make it recognise the 3 wheel outputs. I've done what I thought would work however it does not, even when I land on 3 monkeys.
Any other suggestions are welcome. But please keep in mind that is the most important.
Thank you very much in advance.
The problem that you have here is that your concept of scope needs a little help.
This answer is a really good start.
To make a short example of your code, let's just do this:
def generator(balance):
wheel_1 = 'Monkey'
wheel_2 = 'Diamond'
wheel_3 = 'Heart'
return wheel_1, wheel_2, wheel_3
def win(generator):
print wheel_1, wheel_2, wheel_3
win(generator)
What you'll get here is a NameError, because wheel_1 (and 2 & 3) don't actually exist within the win function. They only exist within the generator function. So what you need to do is get the values from the generator function, and put them somewhere that 'win' can see. You can actually do this pretty easily, since we're already returning the values from the generator function:
# Note: generator was removed as a parameter.
# We don't need it here, because if Python
# can't find the name `generator` it will look
# in the enclosing scope and find the function
# `generator` there.
def win():
# What we want to do is *call* `generator` and
# assign the results to some variables that *are*
# in `win`'s scope
wheel_1, wheel_2, wheel_3 = generator()
print wheel_1, wheel_2, wheel_3
As you mentioned, you can definitely improve some things in your current code. You've noticed inside your generator function there's code that looks almost exactly the same. When you look at code and you get that feeling, that's what's called a "code smell". That's what happens when your (sub)conscious mind sees some code that it knows could be improved. In this particular case there's a principle called DRY - Don't Repeat Yourself.
You can replace your existing code with the following:
def spin_one():
number = random.random()
if number < 0.05:
result = 'Cherry'
elif number < 0.15:
result = 'Diamond'
elif number < 0.30:
result = 'Hearts'
elif number < 0.65:
result = 'Spade'
else:
result = 'Monkey'
return result
def generator():
return spin_one(), spin_one(), spin_one()
And what I might even do is remove the generator call altogether and simply do this:
if all((spin_one() == 'Monkey' for _ in xrange(3))):
You can read the docs on all.
Though, if you want to have more than just win a lot and win a little, then you'd need to keep the values:
wheels = [spin_one() for _ in xrange(3)]
Then you can do:
if all(wheel == 'Monkey' for wheel in wheels):
# Alternatively, wheels.count('Monkey') == 3
print 'Jackpot'
elif wheels.count('Hearts') == 2:
print 'Win'
elif all(wheel == 'Lemon' for wheel in wheels):
print 'You lose'
And any other kind of winning you might want to add.
Prompt
I don't think this is either better or worse than your current prompt approach, but I used to use it all the time in my C++ course.
def prompt():
choice = raw_input('(Y)es or (N)o: ').lower()
if choice == 'y':
return True
elif choice == 'n':
return False
else:
print '**ERROR** Please input "y" or "n"'
return prompt()
It's a nice, simple way to get a handle on recursion :)

While/if loop giving me trouble (beginner)

I have been trying to make my first "solo" python program, its a calculator where you pick what kind of formula you want it to calculate and then input the variables needed. I got issues with my while/for loop, when i run the program i get the correct menu: menu(), and then when I choose my next menu by inputting 1 i correctly get the "v_menu" however if I input 2, which should get me the "m_menu", I instead just get the v_menu like I would if I typed in a 1.
I hope my explanation made sense, im still very new to all of this. Appreciate any help I can get, been breaking my head over this for atleast one hour or so..
Cheers, and heres my code:
# coding=utf-8
#Menues
def menu():
print "Choose which topic you want in the list below by typing the corresponding number\n"
print "\t1) virksomhedsøkonomi\n \t2) matematik\n"
return raw_input("type the topic you want to pick\n >>")
def v_menu():
print "Choose which topic you want in the list below by typing the corresponding number"
print "\t1) afkastningsgrad\n \t2) overskudsgrad\n \t3) aktivernes omsætningshastighed\n \t4) Egenkapitalens forrentning\n \t5) return to main menu\n"
return raw_input("Type the topic you want to pick\n >>")
def m_menu():
print "Choose which topic you want in the list below by typing the corresponding number"
print "\t1) omregn Celsius til Fahrenheit\n \t2) omregn Fahrenheit til Celsius\n"
return raw_input("Type the topic you want to pick\n >>")
# - Mat -
#Celsius to Fahrenheit
def c_to_f():
c_temp = float(raw_input("Enter a temperatur in Celsius"))
#Calculates what the temperatur is in Fahrenheit
f_temp = c_temp * 9 / 5 + 32
#Prints the temperatur in Fahrenheit
print (str(c_temp) + " Celsius is equal to " + str(f_temp) + " Fahrenheit")
#Fahrenheit to Celsius
def f_to_c():
f_temp = float(raw_input("Enter a temperatur in Fahrenheit"))
#Calculates what the temperatur is in celsius
c_temp = (f_temp - 32) * (float(100) / 180)
#Prints the temperatur in celsius
print (str(f_temp) + " Fahrenheit is equal to " + str(c_temp) + " Celsius")
#Program
loop = 1
choice = 0
while loop == 1:
choice = menu()
if choice == "1" or "1)":
v_menu()
elif choice == "2" or "2)":
m_menu()
if choice == "1":
c_to_f()
elif choice == "2":
f_to_c()
loop = 0
Your problem is in your if statements: if choice == "1" or "1)":
What you really need is: if choice == "1" or choice == "1)":
Everything after the or gets evaluated as another expression. You're saying "if choice is equal to one or if one exists."
"1)" evaluates to "true" in this instance, so you'll always hit that branch.
The problem is here;
if choice == "1" or "1)":
v_menu()
elif choice == "2" or "2)":
You have to write them like;
if choice == "1" or choice == "1)":
v_menu()
elif choice == "2" or choice == "2)":
Otherwise, all the time your if statement is True. And if first if statement is True, then your elif statement is not going to work. That's why you can't call v_menu()

Categories