ユーザがexitを入力するまで、次のプログラムを続けると非常に単純なwhile
ループステートメントは何でしょうか?例えばPythonで単純なwhileループを繰り返す
、これまで
while response = (!'exit')
continue file
else
break
print ('Thank you, good bye!')
#I know this is completely wrong, but it's a try!
マイファイル:あなたが設定した条件が偽になるまで
#!/usr/bin/python
friends = {'John' : {'phone' : '0401',
'birthday' : '31 July',
'address' : 'UK',
'interests' : ['a', 'b', 'c']},
'Harry' : {'phone' : '0402',
'birthday' : '2 August',
'address' : 'Hungary',
'interests' : ['d', 'e', 'f']}}
response = raw_input("Please enter search criteria, or type 'exit' to exit the program: ").split()
try:
print "%s's %s is %s" % (response[0], response[1], friends[response[0]][response[1]])
except KeyError:
print "Sorry, I don't know about that. Please try again, or type 'exit' to leave the program: "
:あなたは契約ブレーカである他のいくつかの条件があるかもしれません – user1374310