+ 6
How can I reverse the string in Python?
7 Antworten
+ 2
print("String"[::-1]
+ 18
print(input()[::-1])
+ 5
x='hello'
print(x[::-1])
#another approach
print(''.join(reversed(x)))
+ 2
print("text"[::-1])
+ 2
try this:
str1='python'
str2=''
i=len(str1)-1
while(i>=0):
str2+=str1[i]
i-=1
print(str1)
print(str2)
+ 1
using reverse function:
https://code.sololearn.com/cMyes1Ci7YM6/?ref=app
+ 1
a = "hello i am learning python"
print (a[::-1]) # i have used : before -1 two times.