2
Contributors
3
Replies
4
Views
10 Years
Discussion Span
Last Post by Mouche
0

This works:

s = "banana"
s_reversed = s[::-1]

It might be helpful to encapsulate it:

def s_reverse(s):
    return s[::-1]

s = "banana"
s_reversed = s_reverse(s)
print s_reversed # ananab

x = "hello"
x_r = s_reverse(x)
print x_r # olleh
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.