刚接触Python,随便写了几行,在最后想要跳回第5行再来一遍的时候不知道怎么回去了,看度娘说Python没有C一样的goto语句,除非装第三方库,而且还容易跑崩,有什么别的方法可以实现吗?
i = 3
j = 0
import random
a = random.randint(0,10)
temp = input("随机0,指定1:")
x = int(temp)
while (i > 0) and (x == 0):
i = i - 1
a = a * a
print(a)
if (i > 0) and (x == 1) and (x != 0):
shuru = input("请输入:")
b = int(shuru)
while i > 0:
i = i - 1
b = b * b
print(b)
else:
print ('输入错误,请输入1或0')
把下面的语句定义成方法,通过调用方法实现