+ 1
What is reversed function in Python? s= reversed("Hello World!") print(s)
s= reversed("Hello World!") print(s)
3 ответов
+ 3
reversed() is analogous to sorted(). If you run this code, have a look at the last paragraph printed.
https://code.sololearn.com/cHAqka9YOVph
+ 2
+ 2
reversed return an iterator of iterable passed as argument in reverse order...
to reverse a string, use:
s = "".join(reversed("Hello World!"))
or better use slicing:
s = "Hello World!"[::-1]