Instead of writing many ands how to short your code in pythonic way
Question:
sv= 0.000324
if sv != 0.00002 and 0.00003 and 0.00004 and 0.00005 and 0.0002 and 0.0003 and 0.0004 and 0.0005 and 0.000003 and 0.04 and 0.000000090 and 0.000005 and 0.00003 and 0.000000090 and 0.0000003:
print (sv)
instead of writing many ands or ors is there is a way to make this code shorter or more pythonic way ?
Answers:
Put all the values in a list and check not in. Example Below
sv= 0.000324
not_sv_list = [0.00002, 0.00003, 0.00004, 0.00005, 0.0002, 0.0003, 0.0004,
0.0005, 0.000003, 0.04, 0.000000090, 0.000005, 0.00003, 0.000000090, 0.0000003 ]
if sv not in not_sv_list:
print (sv)
sv= 0.000324
if sv != 0.00002 and 0.00003 and 0.00004 and 0.00005 and 0.0002 and 0.0003 and 0.0004 and 0.0005 and 0.000003 and 0.04 and 0.000000090 and 0.000005 and 0.00003 and 0.000000090 and 0.0000003:
print (sv)
instead of writing many ands or ors is there is a way to make this code shorter or more pythonic way ?
Put all the values in a list and check not in. Example Below
sv= 0.000324
not_sv_list = [0.00002, 0.00003, 0.00004, 0.00005, 0.0002, 0.0003, 0.0004,
0.0005, 0.000003, 0.04, 0.000000090, 0.000005, 0.00003, 0.000000090, 0.0000003 ]
if sv not in not_sv_list:
print (sv)