Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/343.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 如何打印,仅执行一次_Python - Fatal编程技术网

Python 如何打印,仅执行一次

Python 如何打印,仅执行一次,python,Python,我正在尝试制作一个代码,其中说出一个单词将显示一个列表,但我希望第一次打印只打印一次,然后显示列表的其余部分。但是,第一次打印,在每个项目添加任何关于如何打印的想法后显示,所以第一次打印有一个计数器?谢谢你的帮助 if response == "done": count = 0 while count < len(todos): print("**Treasure entry complete! Here is the treasure**"),

我正在尝试制作一个代码,其中说出一个单词将显示一个列表,但我希望第一次打印只打印一次,然后显示列表的其余部分。但是,第一次打印,在每个项目添加任何关于如何打印的想法后显示,所以第一次打印有一个计数器?谢谢你的帮助

if response == "done":
    count = 0
    while count < len(todos):
        print("**Treasure entry complete! Here is the treasure**"),
        print("-",todos[count])
        count = count + 1
if response==“done”:
计数=0
当计数
如果响应==“完成”:
计数=0
打印(“**宝藏条目完成!这是宝藏**”),
当计数
这就是解决方案。你想要!或者请放置预期的输出,以便v可以解决您的问题。您通过删除代码销毁了问题。谢谢!我不知道为什么我不能早点弄明白!
if response == "done":
    count = 0
    print("**Treasure entry complete! Here is the treasure**"),
    while count < len(todos):

        print("-",todos[count])
        count = count + 1