117k views
1 vote
Python Elif Function

1 Answer

0 votes
The python elif function is a part of the if loop and can be used when we have more than two conditions. Usually, you would want to do something like this:

def random_function(variable):
if variable equals 10:
return y
elif variable equals 11:
return x
else:
return z.

As you can see, with this you can control for the different things that variable can stand for.

I wrote this in pseudocode so it's easier to understand :)

User Frank Schwieterman
by
7.8k points