2016-09-14 1 views
-3

내가 이걸 실행할 때, 내가 채팅을 입력하면 위의 농담에서 punchline을 어떻게 실행합니까? enter image description herePython 농담 또는 채팅 오류

print ("whats your name?") 
firstname = input() 
print ("hello,", firstname) 
print ("what's your surname?") 
surname = input() 

fullname = (firstname +" "+ surname) 
print ("hello,", fullname) 

print ("what shall i call you on a daily basis?") 
name = input() 
print ("Glad to meet you,", name) 


print ("is there anything you would like to do?") 
print (" you can 'hear a joke' or 'have a chat'") 


question = input("joke or chat?") 
if question == "joke": 
print("what do you call a deer with no heart?") 
idk = input() 
print ("Dead!!! LOL!!!!") 

if question == "chat": 
print("what games do you like?") 
game = input() 
print ("NO way i love,", game) 
+0

그것은 그것이해야 할 일을하고있는 것처럼 보이지만, 나는 심지어 들여 쓰기로 실행되는 것이 놀랍습니다. Python은 중괄호가 없기 때문에 블록을 들여 써야합니다. – Li357

+0

어떤 버전의 파이썬입니까? –

답변

1

귀하의 간격/들여 쓰기가 꺼져 있습니다 : 당신은에 들여 쓰기를 위해 1 개 이상의 공간을 사용한다 :

if question == "joke": 
print("what do you call a deer with no heart?") 
idk = input() 
print ("Dead!!! LOL!!!!") 

PS : 당신의 코드에서

if question == "joke": 
print("what do you call a deer with no heart?") 
idk = input() 
print ("Dead!!! LOL!!!!") 

이 있어야한다 읽을 수있게 해줍니다. 예컨대 : 적절한 압흔이없는

if question == "joke": 
    print("what do you call a deer with no heart?") 
    idk = input() 
    print ("Dead!!! LOL!!!!") 
+0

파이썬은 들여 쓰기에 4 칸을 사용하도록 제안합니다. –

1

파이썬 라인

idk = input() 
print ("Dead!!! LOL!!!!") 

if 문 밖에 있다고 가정한다. 들여 쓰기는 펀치 라인에 대한 print 성명과 같습니다.

관련 문제