-3

when i executed the below code it is not printing ("yes we can"), its only printing ("all the best"). I am running the code in the visual studio. Executing statement inside if block is not printing in python.

code:

team = input("your favorite team")
if team == "Ferrari" :
    print("yes we can")
print("all the best")

enter image description here

may anyone please help me.

1 Answers1

2

The image you show indicates a leading space before "Ferrari" which you don't have in your prompt. The strings must be identical. When I run your code:

your favorite teamFerrari
yes we can
all the best

But you show a leading space:

your favorite team Ferrari
all the best

You can fix this in a number of ways. First choose a better prompt. Second, strip leading and trailing whitespace:

team = input("Your favorite team: ").strip()
cdarke
  • 42,728
  • 8
  • 80
  • 84