prints the sentence “Yes - Spathiphyllum is the best plant ever!” to the screen if the inputted string is "Spathiphyllum"
(upper-case)
prints “No, I want a big Spathiphyllum!” if the inputted string is “spathiphyllum” (lower-case)
prints “Spathiphyllum! Not [input]!” otherwise. Note: [input]` is the string taken as input.
What’s your code so far?
plant_name = str(("Enter the plant name: "))
name = Spathiphyllum
if plant_name == name:
print ("Yes - ", plant_name, "is the best plant ever.")
This is what I have written so far.
plant_name = str(input("Enter the plant name: "))
Sorry, this is the first line of code.
Thanks
You need an if-elif-else
, you got the if-part down, just add an elif and else.
if num > 5:
print("Number is bigger than 5")
elif num > 0:
print("Number is bigger than 0 and smaller than 5")
else:
print("Number is negative")
@jagaya thanks.
plant_name = str(input("Enter the plant name: "))
fruit_name = plant_name
if fruit_name is plant_name:
print("Yes -", fruit_name, "is the best plant ever!")
First line achieved. Thanks to all
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>
) to add backticks around text.
See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.