创建一个程序,告诉您离开家时是否需要雨伞。未接收输出,而是接收出口代码0

发布于 2025-02-07 04:08:56 字数 316 浏览 1 评论 0原文

我正在尝试创建一个程序,该程序最终告诉您是否需要雨伞(一个非常简单的程序),我只需要是/否输出。但是,这是我使用的代码,我根本没有输出。我只能获得退出代码0,我需要修复什么,以便收到输出以及退出代码0?

感谢您的帮助。新手在这里。

 weather = input('Is it raining today? option Yes/No')
if weather == 'Yes':
      print('Bring an umbrella')
  if weather == 'No':
   print('No umbrella needed')

I am trying to create a program that ultimately tells you if you need an umbrella (a very simple program) I only need a Yes/No output. However, this is the code I have used and I am not getting an output at all. I am only getting exit code 0, what do I need to fix it so that I receive the output as well as exit code 0?

Thank you for your help. Newbie here.

 weather = input('Is it raining today? option Yes/No')
if weather == 'Yes':
      print('Bring an umbrella')
  if weather == 'No':
   print('No umbrella needed')

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

落叶缤纷 2025-02-14 04:08:57

修复凹痕并使用elif

weather = input('Is it raining today? option Yes/No')
if weather == 'Yes':
    print('Bring an umbrella')
elif weather == 'No':
    print('No umbrella needed')
else:
    print('Type: Yes or No')

Fix the indentation and use elif:

weather = input('Is it raining today? option Yes/No')
if weather == 'Yes':
    print('Bring an umbrella')
elif weather == 'No':
    print('No umbrella needed')
else:
    print('Type: Yes or No')

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文