I am making a code which needs me to move the first variable of every list I have into one single list.
For example:
Week1 = [2,3,4,5,6]
Week2 = [3,2,5,6,4]
# I would need to get a list that read
Week_1 = [2,3]
This would be on quite a large scale wit 20 or so variables. I have an idea in mind:
Week1 = [0, 1, 2, 2, 1]
Week2 = [4, 3, 1, 6, 3]
Week = []
i = 1
while i >= 20:
Week = Week.extend((Week + i) [0])
i = i + 1
print (Week)
This probably won't work i know, but would it be possible for the 'week + i' to relate to the variable, so the code would extend by 'Week1 [0]'? This would mean that as the loop progresses it would add the first variable of each list to the other list I believe. Are there any more efficient ways of doing this? Or is there a way for this to work?