mercredi 4 août 2021

simplify complex logical condition in python

How can I simplify this complex logical condition?

For a much shorter and more readable code

if i < 13:
    linux0[j] = query_res
elif 13 <= i < 27:
    linux1[j] = query_res
elif 27 <= i < 28:
    linux2[j] = query_res
elif 28 <= i < 33:
    linuxDnsServer1[j] = query_res
elif 33 <= i < 41:
    linuxRadius[j] = query_res
elif 41 <= i < 46:
    gen[j] = query_res
elif 46 <= i < 49:
    cdu[j] = query_res
elif 49 <= i < 55:
    avalanche[j] = query_res
elif 55 <= i < 69:
    defensePro_devices[j] = query_res

Aucun commentaire:

Enregistrer un commentaire