2016-11-14 12 views
0

基本的には、FORループを使用して、特定のアクタがムービーに含まれていても印刷されていない場合は、そのアクタと女優のユーザー名に検索と印刷を依頼しています映画の中で。イムは非常にこれまでに立ち往生し、あなたが基本的な考え方を持っているようPython 2.7 FORループの使用

print ("Which actor/actress you want to look for?") 
actors [] 
for actor in actors: 
    If actor == actors: 
    print ("Yes, %s is in the show breaking bad") (actors,) 
    break 
    else: 
    print ("NO , %s is not in the show breaking bad") (actors,) 
    print actor 

答えて

0

が見える私の俳優のための私のコードを依頼する方法を知りませんが、あなたのコードは、すべての場所です。

ような何か試してみてください:あなたが入力がリストに名前になるまで尋ね続けたい場合はループを使用し、

search_name = raw_input('Please enter the actor to search for: ') 
actors = ['Idris Elba', 'Dwayne Johnson', 'Mel Brooks'] 

if search_name in actors: 
    print search_name + 'is in the movie!' 
else: 
    print search_name + 'is NOT in the movie!' 

を:

search_name = raw_input('Please enter the actor to search for: ') 
actors = ['Idris Elba', 'Dwayne Johnson', 'Mel Brooks'] 

while search_name not in actors: 
    print search_name + 'is NOT in the movie!' 
    search_name = raw_input('Please enter a different actor's name:') 

print search_name + 'is in the movie!'