0

Good night. Who tells me what error this code has?

color = input() red = 1 green = 2 black = 3 if color == red: print (red) elif color == green: print (green) elif color == black: print (black) else: print ("another color") note: It won't let me print the assigned numbers in the colors. just print the string "another color"

15th Jan 2022, 2:20 AM
Jefferson Jesus Beleño Suarez
Jefferson Jesus Beleño Suarez - avatar
2 Answers
+ 8
color is a string while other variables are integers. So, you can't compare like this. Try using quotes to convert them to strings. "red", "green"...
15th Jan 2022, 2:33 AM
Simba
Simba - avatar
+ 4
Simba wow! Thanks.
15th Jan 2022, 2:39 AM
Jefferson Jesus Beleño Suarez
Jefferson Jesus Beleño Suarez - avatar