go to line in python

Solutions on MaxInterview for go to line in python by the best coders in the world

showing results for - "go to line in python"
Silvana
09 Sep 2020
1def goto(linenum):
2    global line
3    line = linenum
4
5line = 1
6while True:
7    if line == 1:
8        response = raw_input("yes or no? ")
9        if response == "yes":
10            goto(2)
11        elif response == "no":
12            goto(3)
13        else:
14            goto(100)
15    elif line == 2:
16        print "Thank you for the yes!"
17        goto(20)
18    elif line == 3:
19        print "Thank you for the no!"
20        goto(20)
21    elif line == 20:
22        break
23    elif line == 100:
24        print "You're annoying me - answer the question!"
25        goto(1)
26