Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Loops 关于在python中猜数字游戏的查询?_Loops_For Loop_While Loop - Fatal编程技术网

Loops 关于在python中猜数字游戏的查询?

Loops 关于在python中猜数字游戏的查询?,loops,for-loop,while-loop,Loops,For Loop,While Loop,我做了一个随机猜谜游戏,玩家必须猜出电脑给出的数字。但这里有个问题。当答案错误时,我会给出一个提示,但在获得提示后,如果不重新启动程序,该人员如何再次回答? 我的代码是: n = [0,1,2,3,4,5,6,7,8,9] r = random.randint(0, 10) r2 = random.randint(3, 6) print(r) #this is the no. compputer gives guess = 8 #this is the

我做了一个随机猜谜游戏,玩家必须猜出电脑给出的数字。但这里有个问题。当答案错误时,我会给出一个提示,但在获得提示后,如果不重新启动程序,该人员如何再次回答? 我的代码是:

   n = [0,1,2,3,4,5,6,7,8,9]

   r = random.randint(0, 10)
   r2 = random.randint(3, 6)

   print(r)  #this is the no. compputer gives

   guess = 8   #this is the no. tht the player must guess
   if guess == r:
       print("Hurray u won!")
   else:
       print("U lost mfk!")
       y = r*r2
       print("The number is a factor of :" + str(y))  #clues```