2016-11-30 4 views
0

私は友人の誕生日プレゼントを作っています。私は今までのすべてのMarvel Characterのデータベースを作っています。私はこれまでに2つを行って、それを試してみるとエラーと言います。私はコード全体を見て、私は多くを試してみましたが、それは動作していないようです。ここにコードがあります。Pythonでエラーを見つけるのに苦労します

from time import sleep 

print ("Welcome to the Marvel Database please input the name of a marvel character you want to research. Please make sure you type the name as accurately as possible.") 
character = input() 

if character == 'A-Bomb': 
    print ("loading", sleep(.5), ".", sleep(.5), ".", sleep(.5), ".") 
    print ("Character found.") 
    sleep(.5) 
    print ("Name is A-Bomb.") 
    sleep(1) 
    print ("Unknown if they or it are Hero or Villan.") 
    sleep(1) 
    print ("No infomation found.") 
    sleep(1) 

elif character == 'a-bomb': 
    print ("loading", sleep(.5), ".", sleep(.5), ".", sleep(.5), ".") 
    print ("Character found.") 
    sleep(.5) 
    print ("Name is A-Bomb") 
    sleep(1) 
    print ("Unknown if they or it are Hero or Villan.") 
    sleep(1) 
    print ("No infomation found") 
    sleep(1) 

elif character == 'a bomb': 
    print ("loading", sleep(.5), ".", sleep(.5), ".", sleep(.5), ".") 
    print ("Character found.") 
    sleep(.5) 
    print ("Name is A-Bomb") 
    sleep(1) 
    print ("Unknown if they or it are Hero or Villan.") 
    sleep(1) 
    print ("No infomation found") 
    sleep(1) 

elif character == 'A-bomb': 
    print ("loading", sleep(.5), ".", sleep(.5), ".", sleep(.5), ".") 
    print ("Character found.") 
    sleep(.5) 
    print ("Name is A-Bomb") 
    sleep(1) 
+7

:)「爆弾」をあなたは、各順列のために別々のifを作成する必要はありません上記のコードは、「原爆」のいずれかの総額で動作しますか? – dorukayhan

+0

あなたのコードを強調表示し、将来は '{}'ボタンを使用する必要があります。 –

+1

'print(sleep(0.5))'は 'time.sleep()'の戻り値を出力します。これは常に 'None'です。 'sleep()'は 'print()'の前に評価されるので、スリープスリーププリントは 'sleep(1.5);とほぼ同じです。 print(...) ' – dhke

答えて

2
from time import sleep 

print ("Welcome to the Marvel Database please input the name of a marvel character you want to research. Please make sure you type the name as accurately as possible.") 
character = input().lower() 

a_bomb_list = ["a-bomb", "a bomb"] 

if character in a_bomb_list: 
    print ("loading", sleep(.5), ".", sleep(.5), ".", sleep(.5), ".") 
    print ("Character found.") 
    sleep(.5) 
    print ("Name is A-Bomb.") 
    sleep(1) 
    print ("Unknown if they or it are Hero or Villan.") 
    sleep(1) 
    print ("No infomation found.") 
    sleep(1) 

エラーで何

関連する問題