I have been going-through the Python syllabus for about 3 days and I am at the “Learning about Loops” section. We had added lists to lists on a few of the topics and I was wondering how I could interlace 2 lists. Anyway, after about an hour of staring at the screen and trying different things, I figured it out. Here is the code I wrote:
students_period_A = [“Alex”, “Briana”, “Cheri”, “Daniele”]
students_period_B = [“Dora”, “Minerva”, “Alexa”, “Obie”]
index = 0
for student in students_period_A:
students_period_B.insert(index, student)
index += 2
print(students_period_B)
This was the output:
[‘Alex’, ‘Dora’, ‘Briana’, ‘Minerva’, ‘Cheri’, ‘Alexa’, ‘Daniele’, ‘Obie’]
I know its not a massive achievement but I refused to Google, ChatGPT or use anything, I just starred at the screen and iterated (pun intended) my brain cells until I got the answer.