0

In my code I have to do a check, in which the element is in a list or not. Could take the test if it contained the code:

if (x in y):
    (do something) 

and forcing into the else block. And DONE.

But in case not be contained. I tried, of course, with the "not in" but did not work.

How would you do the programming pseudocode: check if x is not y? In pythonstyle.

ialsafid
  • 25
  • 6
  • 2
    `if x not in y` Would do that for you. – idjaw Apr 17 '16 at 16:25
  • Why did `not in` didn't work? – Daniel Apr 17 '16 at 16:27
  • If you tried `not in` and it didn't work, there's some other problem. That is the correct, Pythonic way to do this. If you post some actual code and your *specific* problem, we might be able to tell you what the real issue is. – Henry Keiter Apr 17 '16 at 16:27
  • Can you explain how "'not in' did not work"? Did you get a syntax error or did you get an unexpected result? In either case, can you add those details to your question? – ayhan Apr 17 '16 at 16:27
  • excuse, then it might be another problem in my code because the "not in" did not work, I'll try doing some simple tests. I swear to you I searched this forum is no longer existed this certainly did not show anything related. I'm learning to use this forum. – ialsafid Apr 17 '16 at 16:55
  • @ialsafid Show your code and explain what you are doing in your code. What inputs you are providing and what is happening that leads you to believe it is not working. It will help the readers also know how to help you as well. – idjaw Apr 17 '16 at 17:27

0 Answers0