사용자가 입력 한 단어와 숫자의 목록을 순서대로 반환하려하지만 모듈을 실행할 때 단어와 값을 입력하면 단어와 값 대신에 없음이 인쇄됩니다. 값을 순서대로.값과 단어 목록을 순서대로 반환하려고 시도합니다.
dictionary = []
value = []
addterm1 = raw_input("Enter a term you would like to add to the dictionary: ")
addterm2 = raw_input("Enter a term you would like to add to the dictionary: ")
addterm3 = raw_input("Enter a term you would like to add to the dictionary: ")
addvalue1 = float(raw_input("Enter a number you would like to add to the set of values: "))
addvalue2 = float(raw_input("Enter a number you would like to add to the set of values: "))
addvalue3 = float(raw_input("Enter a number you would like to add to the set of values: "))
dictionary.append(addterm1)
dictionary.append(addterm2)
dictionary.append(addterm3)
value.append(addvalue1)
value.append(addvalue2)
value.append(addvalue3)
def reverseLookup(dictionary, value):
print dictionary.sort()
print value.sort()
if __name__ == '__main__':
reverseLookup(dictionary, value)
당신은 예를 들어, 루프,이 훨씬 짧은 만들 수 할 수있는 코드를 해결하려면 'for range (3) : value.append (float (raw_input (...))'연속 된 줄에 같은 문자열을 반복하는 것은 쓸데없는 선물이다. – jonrsharpe