提问人:misagh 提问时间:8/27/2023 更新时间:8/27/2023 访问量:37
在 Python 中中断运行程序 [已关闭]
break in running program in python [closed]
问:
当我在终端**中运行此代码时,我应该prees“输入”键以在第 6 行之后运行** 我不知道问题 我正在学习 Python 流程 先感谢大家........
print("hi dear,\n welcom to my program in python")
name = input("please enter your name:")
def greeting(name):
print(input(f"hello dear {name}"))
greeting(name)
question1 = print(input(f"how are you today dear {name}?"))
answer1 = "fine"
if answer1 == True:
print("good to know that\nGood Luck my Friend")
else:
print(input(q2="describe for me what happen to you??!!"))
q2 = ""
if q2 == True:
print("ok,no problem...we can solve it.\nplease call to your best friend or doctor for get better.")
else:
print("contact me on this account\[email protected]!!!")
答:
0赞
Nob0Dy
8/27/2023
#1
试试这个 -
print("hi dear,\n welcom to my program in python")
name = input("please enter your name:")
def greeting(name):
print(f"hello dear {name}")
greeting(name)
question1 = input(f"how are you today dear {name}? ")
answer1 = "fine"
if question1 = answer1:
print("good to know that\nGood Luck my Friend")
else:
q2 = input("describe for me what happened to you??!! ")
if q2 == True:
print("ok, no problem...we can solve it.\nplease call your best friend or doctor to get better.")
else:
print("contact me on this account\[email protected]!!!")
请求输入时,不需要 print 关键字。您必须检查用户是否在第 10 行输入了“fine”。希望这会有所帮助。
评论
0赞
misagh
8/28/2023
是的,谢谢......
0赞
Ahmed Gado
8/27/2023
#2
好的,我不确定你按回车键是什么意思,因为似乎您的任何提示都没有专门要求输入。无论如何,问题是输入不接受任何参数。这意味着 input(q2=“enter a value”) 没有价值。它应该是 q2=inpt(“输入一个值”)。这就引出了另一个问题。在这里,您不是将用户返回的值保存在 中,而是在打印中使用它,并且从打印返回的值存储在 中,其中 是 。单独尝试这一行并打印以了解我的意思。现在我相信你的代码中仍然存在一些逻辑错误,因为你是在输入之后编写的,所以在这种情况下,输入永远不会被存储,因为你覆盖了它。question1 = print(input(f"how are you today dear {name}?"))
question1
question1
None
question1
q2=""
评论
print(input(...))