Python Forum
Trouble figuring out how to pass a value between functions?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trouble figuring out how to pass a value between functions?
#1
Hey all, the following block of code yields a "decide" is not defined

I created a 'decide=input()' inside a function
Is it possible to call 'decide' into a different function?

regPizza = ["Pepperoni", "Hawaiian", "Cheesey Cheese", "Meats' R Us", "Vegatarian"]
premPizza = ["Pepperoni Supreme", "Hawaiian Supreme", "Cheese Supreme", "Meats' R Us Supreme", "Vegatarian Supreme"]
decide = ""
def banner():
    print("-------------------Welcome to Dream Pizzas! Where we care about your money but not you!-------------------")

def pizzaReg():
    print("The following Pizzas all cost $5")
    print(regPizza)
    decide=input("Would you like to view our premium selection of Pizzas? Yes or No")
    return decide


def pizzaPrem(decide):
    if decide == "Yes":
        print("The following  premium Pizzas all cost $13.50")
        print(premPizza)
    elif decide == "No":
        raise SystemExit
    

banner()

pizzaReg()

decide = pizzaPrem()
Reply
#2
assign the result of pizzaReg() to decide, then pass into pizzaReg()

decide = pizzaReg()
 
pizzaPrem(decide)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Pass an object to a class, then make an object of it and pass again TomasAm 11 4,544 Nov-09-2020, 04:47 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020