Python을 처음 사용합니다. while 루프에서는 사용자에게 입력을 요청합니다.이 입력은 dict의 핵심입니다. 그 키의 값을 인쇄하십시오. 이 프로세스는 입력이 dict의 키와 일치하지 않을 때까지 계속되어야합니다. if 문을 사용하여 키가 사전에 있는지 확인합니다. 그렇지 않다면 깨는 while 루프와 같습니다. 지금까지 나는 그것을 깨뜨릴 수 없다. 파이썬은 사용자 입력으로 While 루프 깨기
는 모든Animal_list = {
'lion': 'carnivora', 'bat': 'mammal', 'anaconda': 'reptile',
'salmon': 'fish', 'whale': 'cetaceans', 'spider': 'arachnida',
'grasshopper': 'insect', 'aligator': 'reptile', 'rat': 'rodents',
'bear': 'mammal', 'frog': 'amphibian', 'turtles': 'testudines'
}
while True:
choice = raw_input("> ")
if choice == choice:
print "%s is a %s" % (choice, Animal_list[choice])
elif choice != choice:
break
나는 또한 같은 제안합니다, 파이썬이 시퀀스의 회원을 확인하는 데 사용됩니다 "에서"연산자, 문자열, 튜플 etcetra. 당신은이 링크에서 예를 들어 확인할 수 있습니다 : https://www.tutorialspoint.com/python/membership_operators_example.htm –