+ 1
Is there a built in method to reverse a string in Python
String = 'hello' , output = 'olleh'
4 ответов
+ 3
Just use [::-1]
+ 2
mystring1 = "hello world"
mystring1 = mystring1[::-1]
print(mystring1)
# or...using builtins..
mystring2 = "hello world"
mystring2 = "".join(reversed(mystring2))
print(mystring2)
# or...
mystring3 = "hello world"
print(*reversed(mystring3), sep='')
0
Thanks a lot
0
print("hello"[::-1])