The other day in IRC, I was having fun with typing things backwards. I decided to write a Python script to automate my silliness. I came up with this one-liner:
print ''.join([x for x in reversed(raw_input("String here: "))])
Josh came up with this one-liner:
print "stringtoreverse"[::-1]
The main problem with my script is that it uses “reversed()”, which is a feature available only in Python 2.4.x, so it doesn’t work with my IRC client [it uses the Mac system Python which is 2.3.5]. Plus MacIrssi didn’t like the raw_input(). Josh’s is much simpler and works with all versions of Python. But I think mine looks cooler. ![]()
Post a Comment