Problem solving

cant find where am i wrong here

write a program to check if the user likes car or bike.

  • Take string as an input and assign it to the choice variable.
  • Check if the user input is Car or car. If yes, print I like Car.
  • Also check if the user input is Bike or bike. If yes, print I like Bike.
  • If user input is anything else other than that, print nothing.

This is my code:

Replace ___ with your code

choice = str(input())

check if user entered “Car” or “car”

if choice == ‘car’ or ‘Car’:
print(‘I like Car’)

check if user entered “Bike” or “bike”

elif choice == ‘Bike’ or ‘bike’:
print(‘I like Bike’)


I would skip the “or” keyword. Afterwards the code would look somethibg like this.

choice = str(input("What do you like?")).lower()

if choice == "car":
    print("I like car")
elif choice == "bike":
    print("I like bike")
    print("I dont like anything")

The issue you probably have is, that you probably want to compare “car” and also “Car” to choice. This means you have to use something like this.

if choice == “car” or choice == “Car”:

The other solution would be.

if choice in [“car”, “Car”]:

Hope this answers your question.


thanks but it didnt work maybe something wrong with the web or the coding

When you post code, please quote it using the “</>” button so we can see it exactly. And if something “doesn’t work” tell us what error message is.

Try printing out choice to see if you think it should be equal to any of these.

Your strings appear to be surrounded by what some editors call “smart quotes”. Or it might be the forum doing that. However, @Cupprum your properly displayed code has the same problem.

Needs to be:

if choice == "car" or choice == "Car":

yes it worked now thanks

1 Like

I created the comment from my phone. Funny thing that the first one was formatted properly and the others were not. Thanks for the heads up though. Will make sure to check it twice next time.

I was sure you knew that, and you spotted the mistake (incorrect idiom with or), but it seemed like the OP’s continuing trouble might be from copying your version verbatim.