Home Forums Python Programming Talks Why elif Statement in Python?

This topic contains 0 replies, has 1 voice, and was last updated by  blogger rajeev 7 months, 1 week ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #643

    blogger rajeev
    Keymaster

    While only one of the if or else clauses will execute, you may have a case
    where you want one of many possible clauses to execute. The elif statement
    is an “else if” statement that always follows an if or another elif statement.
    It provides another condition that is checked only if any of the previous conditions were False.

    example code:-

    if name == ‘Alice’:
    print(‘Hi, Alice.’)
    elif age < 12: print('You are not Alice, kiddo.') Thanks to Book--automate the boring stuff

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.