-3

My Python code isn't working. It outputs "HI!" regardless of the input.

WifiPswd = '3JUFJF34AF3LLRAC'
UsrIn = ''
print("Maxi AI v0.2 Booting...")
print("....")
print("....")
print("....")
print("....")
print("....")
print("....")
print("....")
print("....")
print("....")
print("....")
print("....")
print("....")
print("....")
print("....")
print("....")
print("Boot Succesful")
print(" Hi, I'm Maxi Your Virtual Assistant! ")
UsrIn = input(" ")
if UsrIn == "Hi" or "hi" or "Hello" or "hello" or "Hey" or "hey" or       "Hi!" or "hi!" or "Hello!" or "hello!" or "Hey!" or "hey!" or "Hi?" or "hi?" or "Hello?" or "hello?" or "Hey?" or "hey?" or "Hi." or "hi." or "Hello." or "hello." or "Hey." or "hey." or "Bonjour" or "bonjour" or "Bonjour!" or "bonjour!" or "Bonjour?" or "bonjour?" or "Bonjour." or "bonjour." or "Hola" or "hola" or "Hola!" or "hola!" or "Hola?" or "hola?" or "Hola." or "hola." : 
      print("Hi!")
elif UsrIn == "Bye" or "bye" or "Bye-Bye" or "bye-bye" or "See you later" or "see you later" or "Bye!" or "bye!" or "Bye-Bye!" or "bye-bye!" or "See you later!" or "see you later!" or "See You Later" or "See You Later!" or "Bye-bye" or "Bye-bye!" or "Bye." or "bye." or "Bye-Bye." or "bye-bye." or "Bye-bye." or "See you later." or "see you later." or "See You Later." or "Au Revoir" or "au revoir" or "Au revoir" or "Au Revoir!" or "au revoir!" or "Au revoir!" or "Au Revoir." or "au revoir." or "Ciao" or "ciao" or "Ciao!" or "ciao!" or "Ciao." or "ciao." :      
      print("Bye...")
elif UsrIn == "Wifi Password" or "Wifi password" or "wifi password" :
      print( WifiPswd )
else:
      print("I don't Understand.")

Ive tried using multiple ifs instead of Elifs but it still doesn't work

Chris Martin
  • 30,334
  • 10
  • 78
  • 137
Maxbo5020
  • 25
  • 2
  • Try to improve you code. For example for wifi password you can use `elif UsrIn.lower() == 'wifi password'`. For greetings you can look at [regular expressions](https://docs.python.org/3/library/re.html). It makes your code waay shorter :) – Honza Sedloň Aug 20 '17 at 22:08

1 Answers1

1

The issue is that you need to have the check after each part of the if statement.

Right now after it checks for "Hi" reads true because 'hi' is a true value Change all of your stements to something like

if UsrIn == "Hi" or UsrIn =="hi" or UsrIn =="Hello" or UsrIn =="hello" ...

That way it actually checks

Lucas Hendren
  • 2,786
  • 2
  • 18
  • 33