leetcode(1),reverse(python)

<span style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;color:#333333;"><span style="font-size: 14px; line-height: 30px;">
</span></span>

question:(将字符串逆向输出)

Write a function that takes a string as input and returns the string reversed.

Example:
Given s = "hello", return "olleh".

代码实现:

def reverse():
    string = raw_input('input a string:')
    words = []
    strCount = len(string)
    for i in range(strCount):
        words.append(string[strCount- i-1])
        i += 1
    rstr = ''.join(words)
    print rstr
刚入门,欢迎指正

你可能感兴趣的:(LeetCode,python)