直到我无法让我的程序正常继续

蒂莫西·卡尔达拉斯(Timothy Kardaras)

由于您不喜欢我对程序的解释,因此我现在仅将其更改为一个问题:我如何允许程序继续检查输入内容并根据输出结果输入mu来应用规则

x = input("Enter your string: ")
while not set(x).issubset({'m', 'u', 'i'}):
    print("false")
    x = input("Enter your string")
    print("Your String is " + x)
if x == ("mu"):
    print("game complete")
    quit()
   #I understand that right now I am only checking if x is mu and then
#displaying the question input
#not sure how to bring the rules into the loop too
else:
    while x !=("mu"):
        Question = int(input("Which rule would you like to apply? enter numbers 1-4: ")
if Question is 1:
    x = (x + "l")
    print(x)
elif Question is 2:
    print("2")
elif Question is 3:
    print("3")
elif Question is 4:
    print("4")
elif Question is not 1 or 2 or 3 or 4:
    print("invalid rule try again")
丹尼尔

while通过相应地缩进规则,将规则带入-loop:

while x != "mu":
    Question = int(input("Which rule would you like to apply? enter numbers 1-4: ")
    if Question == 1:
        x = (x + "l")
        print(x)
    elif Question == 2:
        print("2")
    elif Question == 3:
        print("3")
    elif Question == 4:
        print("4")
    else:
        print("invalid rule try again")

顺便说一句:我们is不要比较数字。您的最后一个条件elif是错误的,应该Question not in (1, 2, 3, 4)甚至是简单的方法else

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何继续运行程序直到我输入特定字符串?

如何继续分叉进程直到我“几乎”耗尽内存

Jquery 代码工作正常,直到我包含严格模式

如何让我的python脚本等待,直到我告诉它在终端中继续执行?

继续“监控”一个 API 端点,直到我使用 Angular HttpClient 获得我的价值

进程被暂停,直到我关闭程序

程序直到我输入exit才打印结果

我的程序无法正常运行

我的程序无法正常工作

将Google IMA集成到我的应用程序中,无法正常工作

批处理文件直到我退出psexec远程连接后才继续

我如何等待删除的文件,直到我启动的程序完成使用它为止?

我的应用程序阻塞,直到我的请求在Xcode中完成

春季启动和前端的reactjs工作正常,直到我向后端添加安全性

ftdi_sio可以正常工作,直到我使用Windows

我的lex程序无法正常工作

我的链接列表程序无法正常工作

按IP排序,然后继续选择记录,直到我有3个唯一IP

程序按预期工作,直到我向其添加析构函数为止

无法让我的脚本继续尝试使用不同的代理,直到它成功运行

我如何遍历这个,直到我迷失了方向

我无法将引导程序包含到我的 Angular 应用程序中

看到我程序的输出

当我在 python 中绘制一些东西时,程序执行停止,直到我关闭绘图图

我将如何让这个程序接受扫描仪输入,直到我命令它停止接受它们

无法SSH到我的桌面

rsync 工作正常,直到我把它放在 crontab 中(更新:'date' 在 crontab 中不起作用)

Asp.net 核心应用程序随机路由停止工作,直到我回收应用程序池

我正在创建一个 FPS 游戏,但我无法弄清楚如何循环我已附加脚本的敌人的射击动画,直到我的玩家死亡