fork download
  1. #!/usr/bin/env python3
  2.  
  3. from itertools import chain
  4.  
  5. def reorderList(lst):
  6. return list(chain.from_iterable(zip(lst, reversed(lst))))[:len(lst)]
  7.  
  8. if __name__ == '__main__':
  9. print(reorderList([1, 2, 3, 4]))
  10. print(reorderList([1, 2, 3, 4, 5]))
Success #stdin #stdout 0.04s 9572KB
stdin
Standard input is empty
stdout
[1, 4, 2, 3]
[1, 5, 2, 4, 3]