- 定义函数
shift_char()
,接受一个参数word
。 - 在函数内,将单词的每个字母替换为字母表中的下一个字母。
- 最后,返回转换后的单词。
def shift_char(word):
result=""
for i in word:
a=ord(i)+1
result+=chr(a)
return result
# 获取单词
word = input()
# 调用函数
print(shift_char(word))
shift_char()
,接受一个参数word
。def shift_char(word):
result=""
for i in word:
a=ord(i)+1
result+=chr(a)
return result
# 获取单词
word = input()
# 调用函数
print(shift_char(word))