Program calling unwanted functions

Luke Tomaneng luketomaneng at gmail.com
Mon Dec 22 14:55:52 EST 2014


Hello to all those in this forum,
    My code seems to have a mind of its own. I have been writing a program to reenact the "Twenny Wun" Vine video, and it seems to be activating  functions without me calling them. Here is the script:

def kid():
    print "Cameraman: You stupid."
    kid1 = raw_input("Kid: ")
    if kid1.lower() == "no im not" or kid1.lower() == "no i'm not.":
        print "Cameraman: What's nine plus ten?"
        kid2 = raw_input("Kid: ")
        if kid2.lower() == "twenny wun" or kid2.lower() == "twenty-one" or kid2.lower() == "twenty one" or kid2 == "21" or kid2.lower() == "twenny one":
            print """Cameraman: You stupid.
Ending program...
"""
        else:
            print "That is not the right quote."
            kid()
    else:
        print "That is not the right quote."
        kid()
def cameraman():
    cameraman1 = raw_input("Cameraman: ")
    if cameraman1.lower() == "you stupid":
        print "Kid: No I'm not."
        cameraman2 = raw_input("Cameraman: ")
        if cameraman2.lower() == "whats 9 + 10" or cameraman2.lower() == "whats nine plus ten":
            print "Kid: Twenny wun"
            cameraman3 = raw_input("Cameraman: ")
            if cameraman3.lower() == "you stupid":
                print "Ending program..."
                time.sleep(2)
            else:
                print "That is not the right quote."
            cameraman()
        else:
            print "That is not the right quote."
            cameraman()
    else:
        print "That is not the right quote."
        cameraman()
def perspective():
    perspective_request = raw_input("Do you want to be the cameraman or the kid? (type the one you want): ")
    if perspective_request == "cameraman":
        cameraman()
    if perspective_request == "kid":
        kid()
    else:
        print "Invalid input."
        perspective()
def instructions():
    instructions_request = raw_input("Do you want instructions? (type 'yes' or 'no' without the quotes): ")
    if instructions_request == "no":
        perspective()
    if instructions_request == "yes":
        print "This is a reenactment of the 'Twenny Wun' Vine. You can type in the empty space to the right of each ':,' then press [return]. Don't use punctuation."
        perspective()
    else:
        print "Invalid input."
        instructions()
instructions()

The "cameraman" function restarts itself when it ends, and the "kid" function calls "instructions()." Does anyone know why?



More information about the Python-list mailing list