这篇文章主要介绍了python中如何返回执行前边的指令?,具有一定借鉴价值,需要的朋友可以参考下。希望大家阅读完这篇文章后大有收获,下面让小编带着大家一起了解一下。
这可能对你有用。
我还添加了一种方法,这样用户就不能输入任何负的字符串或数字不会c语言直接学python。)l=[]
while q<=0:
try:
q=int(input("Enter a number"))
except:
print("That is not a number!")
continue
while p<=0:
try:
p=int(input("Enter a number"))
except:
print("That is not a number!")
continue
import random
list(range(-q, q))
print(l)
while p != p + 1:
x1 = random.choice(l)
x0 = random.choice(l)
if((q == x0 * x1) and (-p == x0 + x1)):
print(x0, x1)
else:
if((q != x0 * x1) or (-p != x0 + x1)):
continue
这应该回到循环的顶部。
continue命令只能在循环中工作,不能在其他地方工作。。。