2 ms·
In python you can also do ''.join(reversed(s)) It's still not the same as your example, because in C++ you reverse the string in-place. If you have a mutabl
by anonymous 14y ago
In python you can also do
''.join(reversed(s))
It's still not the same as your example, because in C++ you reverse the string in-place. If you have a mutable array-like, you can do
arrayish[:] = reversed(arrayish)
But to me the syntax with `s[::-1]` is already perfectly clear. There is the difference that `reversed` returns an iterator, while `s[::-1]` constructs a new string.