我已經做了一個字典,下面的代碼。我想爲所有值添加一個字符串「英語」,但是因爲它不接受的值是整數。如何添加一個字符串到字典的所有整數值
key = ["I", "you", "we", "us", "they", "their"]
value = list(range(len(key)))
dictionary = dict(zip(key,value))
print(dictionary)
輸出:
{'they': 4, 'I': 0, 'you': 1, 'we': 2, 'us': 3, 'their': 5}
我想下面的輸出:
output = {'they': 'English 4', 'I': 'English 0', 'you': 'English 1', 'we': 'English 2', 'us': 'English 3', 'their': 'English 5'}
你列出的值不是合法的Python。你想要一個字符串「英語0」,還是一個元組(「英語」,0)或其他? – Prune
^建議編輯。 @Prune –
我想得到元組 – Daniel