zip multiple values with single value
list, python
Solution
I think a loop like this is clean enough:
ave=['Avg']
lst = []
for x in range(24):
lst.extend((x,ave[0]))
`lst`:
>>> lst
[0, 'Avg', 1, 'Avg', 2, 'Avg', 3, 'Avg', 4, 'Avg', 5, 'Avg', 6, 'Avg', 7, 'Avg', 8, 'Avg', 9, 'Avg', 10, 'Avg', 11, 'Avg', 12, 'Avg', 13, 'Avg', 14, 'Avg', 15, 'Avg', 16, 'Avg', 17, 'Avg', 18, 'Avg', 19, 'Avg', 20, 'Avg', 21, 'Avg', 22, 'Avg', 23, 'Avg']
Problem
I have a list: ``` ave=['Avg'] ``` and another one: ``` range(0,24) ``` How do I zip them so I will have: ``` [0,'Avg',1,'Avg',....23,'Avg'] ``` It is preferred not to have each entry in brackets ie ``` [[0,'Avg'],[...]] ``` since I would later want to make that list into a CSV. I know I could do it with a simple loop, but is there a more clean-cut way? a function maybe?