Python 如何重新启动包含在函数中的代码?

Python 如何重新启动包含在函数中的代码?,python,python-3.x,Python,Python 3.x,我想在用户输入“是”后从一开始就重新启动python代码,但我不明白我在这里做错了什么: if input("Other questions? ") == 'yes' or 'yeah': main() else: pass 我的代码包含在函数main()中。 谢谢你的帮助 你可能会围绕着你想要重复的整个事情做一个while循环,正如Loic RW在评论中所说的,只要打破while循环: while True: # do whatever you w

我想在用户输入“是”后从一开始就重新启动python代码,但我不明白我在这里做错了什么:

if input("Other questions? ") == 'yes' or 'yeah':
    main()
else:
    pass
我的代码包含在函数main()中。
谢谢你的帮助

你可能会围绕着你想要重复的整个事情做一个while循环,正如Loic RW在评论中所说的,只要打破while循环:

while True:
    # do whatever you want

    # at the end, you ask your question:
    if input("Other questions? ") in ['yes','yeah']:
        # this will loop around again
        pass
    else:
        # this will break out of the while loop
        break

你可能会围绕着你想要重复的事情做一个while循环,正如Loic RW在评论中所说的,只要打破while循环:

while True:
    # do whatever you want

    # at the end, you ask your question:
    if input("Other questions? ") in ['yes','yeah']:
        # this will loop around again
        pass
    else:
        # this will break out of the while loop
        break

你能详细说明出了什么问题吗?对于关闭此问题的人来说,你链接的问题/答案似乎与此问题完全无关?@kamion No,
input(“其他问题?”)==“yes”或“yes”
是问题所在,链接的问题解释了如何解决问题。(注意:我没有结束问题)你能详细说明出了什么问题吗?无论是谁结束了这个问题,你链接到的问题/答案似乎与这个问题完全无关?@kamion No,
input(“其他问题?”)==“yes”或“yeah”
是问题所在,链接的问题解释了如何解决它。(注意:我没有结束问题)
如果
语句无论你通过什么都是正确的,你也可以写
,而true:
然后在
else
下写
break
oops。我只是复制并粘贴了原始代码,没有仔细查看。我的错。编辑了if条件。谢谢@RustamGarayevthanks的帮助,我会有一个look@LoicRW是的,这也是可以做到的。
如果
语句无论通过什么都是真的,那么你也可以写
,虽然是真的:
,然后在
else
write
break
oops下。我只是复制并粘贴了原始代码,没有仔细查看。我的错。编辑了if条件。谢谢@RustamGarayevthanks的帮助,我会有一个look@LoicRW是的,那也是可以做到的。