2 odpowiedzi
+ 2
String = "sample string"[::-1]
print(String)
In my example, I used a slice that steps backwards, -1.
From my example above, the slice statement [::-1] means begin at the end of the string (letter "g" in string) and end at position 0 (the first letter at the beginning; "s in sample"), move with the step -1, negative one, which means one step backwards.
Printing the string will output the reverse of the string.
I hope this helps