According to reverse-a-string-in-python, the solution would be
'hello world'[::-1]
To make it more readable, I have to define a function:
def reverse(target_string):
return target_string[::-1]
According to reverse-a-string-in-java, the solution would be
new StringBuilder('hello world').reverse().toString()
I think for Python, there should be a method called reverse()
to let me use it like 'hello world'.reverse()
.