top of page

if-elif-else instructions


 

Scenario

Spathiphyllum, more commonly known as a peace lily or white sail plant, is one of the most popular indoor houseplants that filters out harmful toxins from the air. Some of the toxins that it neutralizes include benzene, formaldehyde, and ammonia.

Imagine that your computer program loves these plants. Whenever it receives an input in the form of the word Spathiphyllum, it involuntarily shouts to the console the following string: "Spathiphyllum is the best plant ever!"

 

Code

this_plant = input("Enter a plant: ") if this_plant == "Spathiphyllum": print("Yes - Spathiphyllum is the best plant ever!") elif this_plant == "spathiphyllum": print("No, I want a big Spathiphyllum!") else: print("Spathiphyllum! Not", this_plant,"!")


bottom of page