+ 6

How can I reverse the string in Python?

3rd Sep 2018, 2:32 PM
Subhash Chaudhary
Subhash Chaudhary - avatar
7 ответов
+ 2
print("String"[::-1]
4th Sep 2018, 2:53 AM
Subhash Chaudhary
Subhash Chaudhary - avatar
+ 18
print(input()[::-1])
3rd Sep 2018, 2:38 PM
Frost
Frost - avatar
+ 5
x='hello' print(x[::-1]) #another approach print(''.join(reversed(x)))
3rd Sep 2018, 4:42 PM
Maninder $ingh
Maninder $ingh - avatar
+ 2
print("text"[::-1])
5th Sep 2018, 5:15 AM
Baltazarus
Baltazarus - avatar
+ 2
try this: str1='python' str2='' i=len(str1)-1 while(i>=0): str2+=str1[i] i-=1 print(str1) print(str2)
6th Sep 2018, 3:25 AM
Nikhil Singh
Nikhil Singh - avatar
4th Sep 2018, 10:37 AM
Samces
+ 1
a = "hello i am learning python" print (a[::-1]) # i have used : before -1 two times.
5th Sep 2018, 2:03 PM
Abhay Singh
Abhay Singh - avatar