1pip install goto-statement
2
3# https://github.com/snoack/python-goto
4
5from goto import with_goto
6
7@with_goto
8def range(start, stop):
9 i = start
10 result = []
11
12 label .begin
13 if i == stop:
14 goto .end
15
16 result.append(i)
17 i += 1
18 goto .begin
19
20 label .end
21 return result
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