I'm a python newbie, and I'm wondering if someone could explain what the operation :: in [1::2] is called and what it does? I understand this is operation on list and what the code does is it prints out the even number lines.
- Code: Select all
with open('file.txt','r') as f:
... print ''.join(f.readlines()[1::2])