7 ответов
+ 6
Ali M ,
the solution print(txt[::-1]) is not indexing it is called *slicing*.
here is a link to a short tutorial about slicing in python:
https://www.sololearn.com/learn/Python/2453/?ref=app
+ 3
"Reverse string in Python (6 different ways) - GeeksforGeeks" https://www.geeksforgeeks.org/reverse-string-python-5-different-ways/amp/
Look it there is 6 ways to reverse string in python
+ 1
oh i searched on google and i found a very good way!
using like indexing like in lists !!
print(txt[::-1]))
well that is good to know, i will leave it, it might help some people !
+ 1
Ali M there are many ways that can do it but simplest way is str[::-1] and it works also on lists
https://code.sololearn.com/c4RSAEkmob8g/?ref=app
+ 1
txt = "Ali"
txt = txt[::-1]
print(txt)
0
Lothar
thanks for the correction, what about list indexing? how it looks like
it has been a long while I didn't practice programing