Answers for "how to continue a elif in python"

17

elif python

The elif statement allows you to check multiple expressions for TRUE 
and execute a block of code as soon as one of the conditions evaluates
to TRUE. Similar to the else, the elif statement is optional. However,
unlike else, for which there can be at most one statement, there can 
be an arbitrary number of elif statements following an if.

if expression1:
   statement(s)
elif expression2:
   statement(s)
elif expression3:
   statement(s)
else:
   statement(s)
Posted by: Guest on April-17-2020
0

python in line elif

# You can nest if/else to get the same effect as elif but it's hard to read and not recommended
msg = "Hi " + ("there" if not name else ("Neo" if name == "Anderson" else name))
Posted by: Guest on July-27-2021

Python Answers by Framework

Browse Popular Code Answers by Language