uykjgfh 发表于 2015-7-31 09:04:09

【python】 倒序输出字符串

Title :
    编写一个程序,获取用户输入的一条信息,然后将其倒序输出。

Code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Reverse Word
# By Dolphin,20150730
#

word = input("Please Enter a word :")

# creat a jumble word
jumble = ""
position = len(word) - 1

while word and position != -1 :
    jumble += word
    position -= 1

print(jumble)
input("\n Enter the any key to exit !")



页: [1]
查看完整版本: 【python】 倒序输出字符串