Python Principles
Python Q&A

How do you reverse a string in Python?

Answer:

Use list slicing with a negative step:

string = "This is a test"
reverse = string[::-1]
print(reverse)

When run, this prints:

tset a si sihT

This syntax works for lists and other enumerables, too:

>>> print([1,2,3][::-1])
[3, 2, 1]