2017-09-04 3 views
-11

Ich verstehe nicht, was ist falsch mit meinem Code? Immer wenn ich hey, hi oder sup tippe, zeigt es nicht an, was ich in den Code geschrieben habe, aber zeigt etwas anderes - was ist der Fehler, den ich machte?Ich verstehe nicht, was ist falsch mit meinem Code?

Hier ist mein Code:

import os 
import random 
import time 

for i in range(1, 2): 

    a = random.choice(("hi, sir", "hey, sir", "hello, sir", "sup, sir", "Joe Reporting, Sir")) 
    print(a) 
    os.system("say '"+a+"'") 


res1 = input() 

if res1 is ("hi", "hey", "hello", "sup", "Hey Joe"): 
    GE = ("I am Joe, Your New Personal Assintant. Nice to meet you.") 
    print(GE) 
    os.system("say '"+GE+"'") 
else: 
    js = random.choice(("okay, what would you like to do", "So, Sir What Would you like to do ", "So Sir, What to do", "k, what are we going to do")) 
    print(js) 
    os.system("say '"+js+"'") 


User_inp = input() 
print("Ok, searching") 
''' 
if inp "?": 
    print("Um...Let me Search") 
''' 
Next_inp = input() 
g = random.choice(("Searching, sir", "I am on it.")) 
print(g) 
+1

'ist in', nicht' ist'. Nachschlagen, wie der Wert in Liste oder Tupel in Python überprüft wird –

+0

^dies ist für die Zeile 'wenn res1 ist ("...."):' und es ist 'in' nicht 'ist in' .. dh wenn res1 in ('hi', 'hey'): – AK47

+3

@LukeK eigentlich 'in', nicht' ist in' – khelwood

Antwort

0

Wie in den Kommentaren erwähnt Sie Ihren Code wie folgt ändern müssen.

res1 = input() 

if res1 in ("hi", "hey", "hello", "sup", "Hey Joe"): 
    GE = ("I am Joe, Your New Personal Assintant. Nice to meet you.") 
    print(GE) 
    os.system("say '"+GE+"'")