0

when I run this code:

def greet(lang):
    if lang == "es" or "espanish":
        print("Hola")
    elif lang == "fr" or "french":
        print("Bonjour")
greet(input ("What is your lang: "))

and when I type in the input fr or french it's always giving me Hola, how I fix it?

ALI_lol
  • 49
  • 6

2 Answers2

2

Try :

def greet(lang):
    if lang == "es" or lang=="espanish":
        print("Hola")
    elif lang == "fr" or lang=="french":
        print("Bonjour")
greet(input ("What is your lang: "))
Charles Dupont
  • 995
  • 3
  • 9
0

This basically evaluates to (lang == "es") or "espabish" where espanish evaluates to true, so the first is always true. Instead I would do lang in ("es", "espanish")

DownloadPizza
  • 3,307
  • 1
  • 12
  • 27