【问题标题】:Issue completing python code for a task问题完成任务的python代码
【发布时间】:2017-03-21 10:09:58
【问题描述】:

您好,我最近开始学习 python,并在整个互联网上搜索了 12 个小时的帮助,试图完成这项任务(这一直困扰着我,哈哈)有人可以帮我完成这项任务,或者至少能够告诉我到目前为止,我目前编写的代码哪里出了问题。

谢谢,提前。

Python Task Question Code I have done so far

【问题讨论】:

  • 如果您需要帮助,建议分享代码,解释错误并分享您尝试过的内容。

标签: python loops while-loop


【解决方案1】:

这应该做你想做的事

while True:
    resp = input("Would you like some advice?")
    if resp not in ["Y", "N"]:
        print("Please enter Y or N only.")
    elif resp == "Y":
        print("Don't feed the trolls!")
        break
    else:
        print("Don't be silly, you definitely need advice!")

如果您使用的是 python 2,请将 input 更改为 raw_input

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-25
    • 2018-06-25
    • 2011-04-20
    • 1970-01-01
    • 2022-11-16
    • 1970-01-01
    相关资源
    最近更新 更多