Answers for "python if not none in one line"

0

python if not none in one line

#if X is None, do nothing
>>> x = ''
>>> x if x and x>0 else None
#if x is not None, print it
>>> x = 1
>>> x if x and x>0 else None
1
Posted by: Guest on July-01-2020
0

python if not none in one line

v = get_value()
x = v if v is not None
Posted by: Guest on July-01-2020

Python Answers by Framework

Browse Popular Code Answers by Language