У меня есть следующее:
device = {
'BPCM' : ['phone', 'Description: Compact', 'price', 29.99],
'BPSH' : ['phone', 'Description: Clam Shell', 'price', 49.99],
'RTMS' : ['Tablet', 'Description: RoboTab - 10-inch screen and 64GB memory', 'price', 299.99],
'RTLM' : ['Tablet', 'Description: RoboTab - 10-inch screen and 256 GB memory', 'price', 499.99],
}
print("Hello customer, here is your list of phone and tablet choices. Please choose a phone or tablet by entering your name and the item code:")
for key, value in device.items():
print("\nItem Code: " + key)
print(" " + str(value))
name = raw_input("\nPlease tell me your name? ")
print("Hello " + name)
response = raw_input("Please enter item code: ")
if response in device.keys():
print("Item Code Chosen " + response + str(value))
else:
print("This code " + response + " is not in our list, please try again or choose quit 'q'")
Эта строка: «print (« Выбранный код товара »+ response + str (значение))», кажется, вызывает проблемы в том, что печатает следующий вывод:
Item Code Chosen BPCM['phone', 'Description: Clam Shell', 'price', 49.99]
Значение, которое печатается выше, является вторым значением в словаре, относящимся к ключу: RTLM, но я ожидаю первое значение, как показано ниже:
'BPCM'['phone', 'Description: Compact', 'price', 29.99]
Я не вижу свою ошибку ?