Steve Holden wrote: >But there's no good reason why there shouldn't be a "reverse" function which >returns the reverse of any sequence, surely? The question then becomes >whether a built-in function could improve on the efficiency of > >>>> def sreverse(s): >... l = list(s) >... l.reverse() >... return "".join(l) >... >>>> sreverse("abcdefg") >'gfedcba' This doesn't work they way your English description says it should; it doesn't work on "any sequence" >>> sreverse([1, 2, 3]) Traceback (innermost last): File "<interactive input>", line 1, in ? File "<interactive input>", line 4, in sreverse TypeError: first argument must be sequence of strings >>> because while a string *acts* like a list or tuple of characters, it really isn't. Andrew dalke at acm.org
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4