我只希望它在每次试验开始时和到达不同位置后出现。不是连续的。
随机导入
while循环返回到开头
while True: trials=int(input(“你想运行多少个试验?”))如果尝试次数<0:打印(“您必须输入一个大于0的值。”)
elif trials>0:用于打印每个试验的for循环
count=0
for x in range(trials):
count+=1
count_trials=print("The Trial is",count)为每个机场分配一个编号
while True:
airports=random.randint(1,4)
print("MCI -> ", end="")
if airports==1:
airports="MCI"
elif airports==2:
airports="LVS"
elif airports==3:
airports="SEA"
elif airports==4:
print("HNL")
break
count_hops=print(airports, end=" -> ")发布于 2016-05-08 21:16:55
我想你需要这个
import random
trials=int(input("How many trials would you like to run?"))
if trials <0:
print("You must enter a value greater than 0.")
elif trials>0:
count=1
true=True
while true==True:
airports=random.randint(1,4)
print("trial no. ->"+str(count))
if count>=trials:
true=False
if airports==1:
airports="MCI"
elif airports==2:
airports="LVS"
elif airports==3:
airports="SEA"
elif airports==4:
airports="HNL"
count+=1
count_hops=print("airport"+" -> "+airports)如果你不能理解某些东西或它不合适,请添加评论
https://stackoverflow.com/questions/35401256
复制相似问题