Ronald bergurman 3rd
Ronald bergurman 3rd

Reputation: 43

I am trying to set a value to 'true' so i can start a program

heres my code:

def start():
     print("Hello world!")
     name=input("Please enter your name: ")
     print("Hi {0}".format(name))
     run=input("type | True | to run the program: ").capitalize()
     if run== "True":
         running = True
     else:
         print("You need to enter | True | to run the program")

def main():
    if running== True:
        print("1 = Add")
        print("2 = Subtract")
        print("3 = Times")
        print("4 = Divide")
        print("5 = Quit program")
        calc=int(input("enter number of choise: "))   

Upvotes: 0

Views: 27

Answers (1)

Keatinge
Keatinge

Reputation: 4341

You never call either function, you need to call one of these functions to start your program, for your desired functionality you need to call start()

Then instead of using that weird running=True (which wouldn't work anyway), just only call your main() if the users enters True

def start():
     print("Hello world!")
     name=input("Please enter your name: ")
     print("Hi {0}".format(name))
     run=input("type | True | to run the program: ").capitalize()
     if run== "True":
         main() #the user typed true, so lets jump to your main function
     else:
         print("You need to enter | True | to run the program")

def main():
    print("1 = Add")
    print("2 = Subtract")
    print("3 = Times")
    print("4 = Divide")
    print("5 = Quit program")
    calc=int(input("enter number of choise: "))   


start() #the program never runs your start function without this line

Upvotes: 1

Related Questions