[Solved] Python (if, else, elif)


if louis_inventory and louis == 0:

This will catch every cases where louis_inventory is truthy – e.g. anything nonzero in case of an int – and louis is zero.

So the first elif case is unreachable. I have no idea what exactly you are trying to do but this might fix it:

def example():
    if louis_inventory == 1 and louis == 0:
        pointstore_skin_ct.addline('->1. Louis (In use)')
    elif louis_inventory and louis == 0:
        pointstore_skin_ct.addline('->1. Louis (650) Perm')
    elif louis_inventory and louis == 1:
        pointstore_skin_ct.addline('->1. Louis (Not in use)')

It will jump into the first block if the value is exactly 1 and in the second one if it’s any other non-zero value.

1

solved Python (if, else, elif)