[討論] 字母平移的程式改進
大家好,一直以來我寫程式就是想辦法得到答案,可是都不清楚如何改進,
因為自己懂的東西總是很少,所以想到說把自己的方法po上來,來看大家
有沒有些不同的想法,不知道這種文是否可以po,有問題請告訴我,我會改進。
--------------------------------------------------------------------
題目:將一個字串的字母上移2個
範例:輸入為abc時,輸出為cde
code:
temp = input("Enter a string: ")
i = len(temp)
temp = list(temp)
j = 0
while(j<i):
temp[j] = chr(ord(temp[j]) + 2)
j += 1
temp = ''.join(temp)
print(temp)
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.113.241.1
※ 文章網址: http://www.ptt.cc/bbs/Python/M.1403838521.A.EBC.html
→
06/27 11:27, , 1F
06/27 11:27, 1F
→
06/27 17:14, , 2F
06/27 17:14, 2F
推
06/28 21:24, , 3F
06/28 21:24, 3F
討論串 (同標題文章)
Python 近期熱門文章
PTT數位生活區 即時熱門文章