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