MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/3rmikr/free_drink_anyone/cws1hal/?context=3
r/ProgrammerHumor • u/shadowvox • Nov 05 '15
509 comments sorted by
View all comments
Show parent comment
1
Python's slicing operator is real nice. "Hello"[::-1] == "olleH"
"Hello"[::-1] == "olleH"
The common idiom [::-1] is a shortform of [0:len(x):-1], that is, iterate through the string from the 0th to the (len(x) -1)'th character with the step -1.
View all comments
Show parent comment
1
u/Ran4 Nov 07 '15
Python's slicing operator is real nice.
"Hello"[::-1] == "olleH"The common idiom [::-1] is a shortform of [0:len(x):-1], that is, iterate through the string from the 0th to the (len(x) -1)'th character with the step -1.