4 ms·
I love interview questions that make Python look awesome.
by jbellis 17y ago
I love interview questions that make Python look awesome.
- Luyt 17y agopython -c "print '\n'.join(open('file.txt').readlines()[::-1])" Hmmm, slightly longer then the Perl version ;-) python -c "print '\n'.join(reversed(list(open('test.py'))))" Somewhat more elegant, but still lots of parentheses.
- RiderOfGiraffes 17y agoIt's also wrong - "readlines" keeps the "\n", and you've added another one between lines.