“ir a Python” Código de respuesta

ir a la línea en Python

def goto(linenum):
    global line
    line = linenum

line = 1
while True:
    if line == 1:
        response = raw_input("yes or no? ")
        if response == "yes":
            goto(2)
        elif response == "no":
            goto(3)
        else:
            goto(100)
    elif line == 2:
        print "Thank you for the yes!"
        goto(20)
    elif line == 3:
        print "Thank you for the no!"
        goto(20)
    elif line == 20:
        break
    elif line == 100:
        print "You're annoying me - answer the question!"
        goto(1)
Adorable Antelope

ir a Python

def func1():
    ...

def func2():
    ...

funcmap = {1 : func1, 2 : func2}

def somefunc(a):
    funcmap[a]()  #Ugly!  But it works.
Crowded Coyote

Respuestas similares a “ir a Python”

Preguntas similares a “ir a Python”

Más respuestas relacionadas con “ir a Python” en Python

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código