0
好了,所以說我有這樣的如何從元組返回一個值
values = ('1', 'cat', '2', 'bat', '3', 'rat', '4', 'hat', '5', 'sat')
我會得到什麼循環功能寫入詢問整數用戶輸入,並使其返回字一個元組。即。用戶輸入1並返回cat。或用戶輸入123,它返回catbatrat(我不需要輸出有空格)
編輯:我知道它會更有意義使用字典,但在這種情況下,我不喜歡。
我的代碼:
values = ('1', 'cat', '2', 'bat', '3', 'rat', '4', 'hat', '5', 'sat')
message = raw_input("Enter a number for the corresponding word: ")
for char in message:
print values
1)請向我們展示您的解決方案嘗試。 2)添加語言標籤。 –