I came across a strange Codecademy exercise that required a function that would take a string as input and return it in reverse order. The only problem was you could not use the reversed method or the common answer here on stackoverflow, [::-1]
.
Obviously in the real world of programming, one would most likely go with the extended slice method, or even using the reversed
function but perhaps there is some case where this would not work?
I present a solution below in Q&A style, in case it is helpful for people in the future.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…