2017-05-20 6 views
0

hiya Ich bin komplett neu in all diesen Programm - und Forum - Sachen und ich weiß nicht genau, was ich tue.Ich versuche gerade mein erstes reales Projekt, das eine kleine Konversation sein soll (Fokus auf letzten Teil von ich habe bisher Codierung)If-Anweisung scheint Elif-Anweisung zu ignorieren. (python)

print('Hello my name is NATBNAT- pronounced Nat.Ben.nat') 

import time 
time.sleep(2) 

human1 = input ('Whats your name if i may ask?') 


import time 
time.sleep(2) # Import time allows for a delay in response. In this situation it has been used to allow for a more 'human' response. 

#The {} let's the '.format' at the end know when to insert 'human1' 
print('{} ....Hmm nice name'.format(human1)) 

import time 
time.sleep(1) 

feeling1 = input("So {} how are you feeling? Unhappy? ok? or Happy?".format(human1)) #once the human has answered ^^^^ question then whatever was the answere will be Feeling1. e.g. 

if(feeling1 == 'unhappy' or 'Unhappy'): 
    print('oh chucks, is there anything i can do to make it better?') 
elif(feeling1 == 'ok' or 'Ok'): 
    print('OOO intresting 0_o . I usually only know the differance between yes/no on/off or happy/unhappy. Please tell me if your ok because you could be better or you just feel worn out') 
elif(feeling1 == 'Happy' or 'happy'): 
    print(' Oh Good ol man ... boy i mean girl... wait... DOH! I dont have eyes or the understanding between Female or Male names -_-') 

es ist alles funktioniert gut in dem Sinne, dass es keine Fehler geben, aber es ist einfach nur sagen, die erste ‚if‘ Anweisung, selbst wenn ich Eingabe ‚oK‘ oder ‚glücklich‘. bitte entschuldigen Sie die Notizen, da sie nur dazu gedacht sind, Erinnerungen für mich selbst zu sein. Danke :)

Antwort

3

if(feeling1 == 'unhappy' or 'Unhappy') nicht tun, was Sie erwarten. Es sollte so aussehen:

if feeling1 == 'unhappy' or feeling1 == 'Unhappy': 

Oder Sie tun können:

if feeling1 in ('unhappy','Unhappy',): 
+0

perfekt dich so sehr danken. Ich wusste nie, dass es auch so schnell beantwortet werden würde: D – SKEthan

Verwandte Themen