0

I am just re-learning Python at the moment, but I have encountered a problem for a very basic inventory system, when I press run and type "No" or "no", it still prints out the len function, any help?

click here to see an image of the code

PM 2Ring
  • 54,345
  • 6
  • 82
  • 182
  • 1
    Please post your code as actual code. No one has fun retyping things from an image. – languitar Apr 28 '17 at 09:05
  • 1
    It should be `a == "Yes" or a == "yes"` in if. Same for elif. – kuro Apr 28 '17 at 09:08
  • 1
    Also, please add your code in text format from now on – kuro Apr 28 '17 at 09:08
  • your `if` statement is written in human logic not computer logic, to explain better your if statement is getting checked at `a=="Yes"` and if you type in anything else then it wont meet the criteria but the `or "yes"` will always evaluate to `True` because it isnt being checked against anything – WhatsThePoint Apr 28 '17 at 09:08
  • 1
    Please see [Why may I not upload images of code on SO when asking a question?](http://meta.stackoverflow.com/questions/285551/why-may-i-not-upload-images-of-code-on-so-when-asking-a-question) – PM 2Ring Apr 28 '17 at 09:09
  • @languitar I don't think embedding that giant image into the question body improves things. – PM 2Ring Apr 28 '17 at 09:11
  • @PM2Ring "enter image description here" also isn't convincing to find code behind the link ;) – languitar Apr 28 '17 at 09:12
  • Also see http://stackoverflow.com/questions/15112125/how-do-i-test-one-variable-against-multiple-values – PM 2Ring Apr 28 '17 at 09:13
  • @languitar Fair point, so I've improved the link text. Ideally, Lorenzo would post the actual code as text, but I guess that's unlikely to happen now that I've closed the question. – PM 2Ring Apr 28 '17 at 09:16
  • @PM2Ring I just have the feeling that there are still more people looking at the question in case there is actual code visible (even as an image) as if there is nothing visible except a link that has to be opened. – languitar Apr 28 '17 at 09:17
  • @languitar Images of code simply don't belong on SO. If the OP won't post the code as text, the link will have to do. The plain text link wastes less screen space (that image is really large on small screens, eg on mobile devices), and the plain text link consumes less bandwidth. If people are really curious they can click the link. – PM 2Ring Apr 28 '17 at 09:28

1 Answers1

1

your code line: replace

if a == "Yes" or "yes"       

to

if a == "Yes" or a == "yes" 
kuro
  • 3,214
  • 3
  • 15
  • 31
JkShaw
  • 1,927
  • 2
  • 13
  • 14