-1

I am a beginner to python and am working on python 3.6.5 , I was trying to create a Chatbot but I don't understand how to use a comma to separate the two strings(red and Red) because the shell says that it is an invalid syntax(the comma is highlighted but nothing else). What have I done wrong?:

colour=input("What is  your favourite colour? ")  
if colour=="red", "Red":  
    print("Red is my favourite colour as well")

note:I know this question is very similar to others on the forum but considering I am only a beginner (I literally started learning python on friday) the answers for the other question were a bit confusing because they had different code,so I asked this question using what I am learning.

smiley21
  • 21
  • 2

2 Answers2

2

Use in

colour= input("What is  your favourite colour? ")  
if colour in ("red", "Red"):  
    print("Red is my favourite colour as well")
rafaelc
  • 57,686
  • 15
  • 58
  • 82
1

You could you use if colour in ['red', 'Red', 'RED', 'ReD'] as mentionned earlier, or you could just sanitize the input:

colour= input("What is  your favourite colour? ")
if colour.lower() == "red":
    print("Red is my favourite colour as well")
JulienCoo
  • 1,128
  • 3
  • 13
  • 24