+ 2

Hello, please how do I reverse a string in python?

13th Sep 2020, 10:38 AM
Black
3 Réponses
+ 9
Apart from using a slice [::-1], there are also some other variants. inp = 'sololearn # comprehension: print(''.join([i for i in reversed(inp)])) # reversed: print(''.join(list(reversed(inp))))
13th Sep 2020, 10:53 AM
Lothar
Lothar - avatar
+ 5
Black , you can do it this way for example. https://code.sololearn.com/cDT44q7Gn8MK/?ref=app
13th Sep 2020, 10:40 AM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
0
str = input() rev = str[::-1] print(rev) It works.
4th Aug 2021, 3:49 AM
Aziz Ergashev
Aziz Ergashev - avatar