Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.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 python程序在空闲状态下运行,而不是在程序中运行_Python 3.x - Fatal编程技术网

Python 3.x python程序在空闲状态下运行,而不是在程序中运行

Python 3.x python程序在空闲状态下运行,而不是在程序中运行,python-3.x,Python 3.x,我是一名第一季度的在线学生,我被卡住了。我的程序输入一个列表,然后以相反的顺序打印列表,列表中的每一项都向后打印。我可以让程序在空闲状态下运行,但是当我在命令窗口中单击要运行的.py文件时,当它到达程序中要打印列表的部分时,命令屏幕就会关闭。我不知道如何排除故障,非常感谢您的帮助 word = input("Enter a word: ") wordList = [] while word != "karyn": wordList.append(word) word = input

我是一名第一季度的在线学生,我被卡住了。我的程序输入一个列表,然后以相反的顺序打印列表,列表中的每一项都向后打印。我可以让程序在空闲状态下运行,但是当我在命令窗口中单击要运行的.py文件时,当它到达程序中要打印列表的部分时,命令屏幕就会关闭。我不知道如何排除故障,非常感谢您的帮助

word = input("Enter a word: ")
wordList = []

while word != "karyn":
   wordList.append(word)
   word = input("Let's keep going.\nEnter another word: ")

wordList.reverse()
for i in wordList:
    print(i[::-1])

只需在脚本末尾暂停它(我假设这里是windows…)


程序可能很好,但cmd在完成后关闭。添加一行,使
cmd
保持打开状态,或手动打开,使其不会关闭。在文件末尾添加
input('Done!按任意键继续)
for i in wordList:
    print(i[::-1])
import os
os.system("pause")