简体   繁体   English

我的python3.6代码的if语句不会打印出print

[英]print won't print in if statement of my python3.6 code

I'm just learning python, complete newbie to coding. 我只是在学习python,是编码的新手。 Below (in the image) is some simple code that I did after doing an exercise in "Learning Python the Hard Way 3". 下面(图中的图像)是我在“学习Python的硬方法3”中的练习后所做的一些简单代码。 What I can't seem to solve is why my "print" after the "if" statements won't print. 我似乎无法解决的问题是为什么我的“ if”语句后的“ print”不打印。 Any suggestions? 有什么建议么?

simple python code 简单的python代码

Your code is asking for input and storing it in the variable snow . 您的代码要求输入并将其存储在变量snow Then your if statement is asking for input again. 然后,您的if语句再次要求输入。

Change line 12 to use the snow variable: if snow == "No": . 更改第12行以使用snow变量: if snow == "No":

The problem's in line 12. You got the user's input in line 10, and set it to the variable snow. 问题在第12行中。您在第10行中获得了用户的输入,并将其设置为变量snow。 When it gets to line 12, it prompts you again because you call input(prompt) again. 到达第12行时,它会再次提示您,因为您再次调用了input(prompt)。 Rather, your code should be like if snow == "No": , then it will use your response without prompting you again. 而是,您的代码应该类似于if snow == "No":那么它将使用您的响应而不会再次提示您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM