I want to cycle values in a loop but also using the zip
function, however the catch is to manipulate those values that are cycled. In this case, if the values are cycled then return a string "None" instead.
For example:
data = {
'carNumbers':[
1, 2, 3, 2, 3, 2, 1, 3
],
'bikeNumbers':[
4, 3, 5
],
'otherNumbers':[
2
]
}
I can do the following:
from itertools import cycle
test={}
for car, bike, other in zip(data['carNumbers'],cycle(data['bikeNumbers']),cycle(data['otherNumbers'])):
print(other)
2 2 2 2 2 2 2 2
However, because other
has a shorter length than the largest length car
those extra values should return the following:
2 "None" "None" "None" "None" "None" "None" "None"