Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.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

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
Python 3.x 我的For循环将break命令列为输出。我如何防止这种情况?_Python 3.x_Loops_For Loop_Output_Break - Fatal编程技术网

Python 3.x 我的For循环将break命令列为输出。我如何防止这种情况?

Python 3.x 我的For循环将break命令列为输出。我如何防止这种情况?,python-3.x,loops,for-loop,output,break,Python 3.x,Loops,For Loop,Output,Break,发生的情况是,当我按enter键中断循环时,它会将我中断循环计算为输出。 例子 1.客人姓名 2.客人姓名 3. < (点击回车键激活中断命令) 将if块放在for循环的输入命令之后 for iii in range(1, 1000): guests = input("....") if guests.lower() == "": break output = output + str(iii) + "." +

发生的情况是,当我按enter键中断循环时,它会将我中断循环计算为输出。 例子 1.客人姓名 2.客人姓名 3. < (点击回车键激活中断命令)

将if块放在for循环的输入命令之后

for iii in range(1, 1000):
    guests = input("....")
    if guests.lower() == "":
        break
    output = output + str(iii) + "." +guests