0
0

More than 1 year has passed since last update.

NLP 100 Exercise 2020 (Rev 2) Chapter 1: Warm-up 00. Reversed string

Last updated at Posted at 2023-01-05

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

この問題では、文字列を逆順に並び替えます。

Reference article

[Python]スライス操作でlistを逆順にする

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0