00. Reversed string
Obtain the string that arranges letters of the string “stressed” in reverse order (tail to head).
solution00.py
# Sequence types (list, tuple, string, range) support slicing.
# Therefore, you can sort in reverse order by setting text[::-1] in the slice operation.
text = "stressed"
print(text[::-1])
# You can also use reversed() method.
print(''.join(reversed(text)))
output
desserts
desserts
この問題では、文字列を逆順に並び替えます。