Python Forum
how to get the value out the def function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to get the value out the def function
#1
Error:
Error : print(choice_cost + car_cost) NameError: name 'choice_cost' is not defined
thank you

"""Total Car Cost"""

car_cost = 500

def total_cost():
    print(choice_cost + car_cost)


def color_cost():
    print()
    print("For Blue Enter 1.","For Red Enter 2" )
    print()
    choice = int(input("Please enter color choice :"))
    if choice == 1:
        choice_cost = 100
        total_cost()
    elif choice == 2:
        choice_cost = 200
        total_cost()
    else:
        print("Invalid Choice. Please choose again")
    color_cost()

color_cost()
Reply


Messages In This Thread
how to get the value out the def function - by dan_py - Mar-09-2019, 05:35 PM

Forum Jump:

User Panel Messages

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