Concat every 4 strings from a list?

ip, list, python, string

Solution

>>> data = ['192', '168', '0', '1', '80', '192', '168', '0', '2', '8080']
>>> ['{}.{}.{}.{}:{}'.format(*x) for x in zip(*[iter(data)]*5)]
['192.168.0.1:80', '192.168.0.2:8080']

Using `starmap`

>>> from itertools import starmap
>>> list(starmap('{}.{}.{}.{}:{}'.format,zip(*[iter(data)]*5)))
['192.168.0.1:80', '192.168.0.2:8080']

Problem

I have this list: ``` ['192', '168', '0', '1', '80', '192', '168', '0', '2', '8080']... ``` And i want to get this list: ``` ['192.168.0.1:80', '192.168.0.2:8080']... ``` What is the best way of doing it ? using `range` with `list` pop ? using `list` slicing ?

Original source