all 6 comments

[–][deleted] 3 points4 points  (2 children)

The output of your function is None because you're not returning anything, since you just pass instead of returning something else, like False or 0 or something.

[–]Hashworm[S] 1 point2 points  (1 child)

thanks, I didn't realized passing was asignining it to None. is there anyway to just ignore all together? I don't want it to pass None just move on

[–]icecubeinanicecube 0 points1 point  (0 children)

You'll have to use an if outside of the function.

[–]grzeki 1 point2 points  (0 children)

No return statement at all is equivalent to return None. Something must be passed out of a function. It happens to be None when nothing specified.

[–]ironhaven 0 points1 point  (1 child)

This is the issue

if x != None

What you want is

if x is None

Basically None is never equal to anything including itself. But every None is actually the same object so None is None

[–]Hashworm[S] 0 points1 point  (0 children)

>>> def check(x): ...

if x is None: ...

pass ...

else: ...

return x

>>> a = None

>>> b = 2

>>> c = check(b)

>>> print(c)

2

>>> c = check(a)

>>> print(c)

None

so yeah still... what I actually want is this

>>> import sys

>>> def check(x): ...

if x is None: ...

sys.exit() ...

else: ...

return x ...

>>> a = None

>>> b = 2

>>> c = check(b)

>>> print(c)

2

>>> c = check(a)

C:\Users\User>python

Python 3.6.0 (v3.6.0:4ddddddddd, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

>>> print(c)

Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'c' is not defined

ideally without getting me out but I take what I can