Answer to Question #289822 in Python for loss

Question #289822

2. Which Color?

by CodeChum Admin

My favorite color is blue. What's your favorite color? Never mind it doesn't matter, as long as you know how to identify which color is given.


Instructions:

  1. Input a string that represents a color.
  2. Print "Red" if the color is red, "Blue" if it is blue, "Green" if it is green, and "None of the Above" if it isn't any of the three colors.
  3. Inputting the strings "ReD" or "rED" should still output "Red", this also applies to the other colors, so make sure to use one of the functions discussed previously!

Input

A line containing a string.

red

Output

A line containing a string.

Red
1
Expert's answer
2022-01-23T10:13:44-0500
color=input("Enter a string representing a color: ")
color=color.lower()
if color=="red":
    print("Red")
elif color=="blue":
    print("Blue")  
elif color=="green":
    print("Green")
else:
    print("None of the Above")
Enter a string representing a color: rEd
Red

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS