#python #anaconda #jupyter-notebook #visual-code #html #css #javascript #http

제목Step 11 3번째 퀴즈 질문2021-04-10 14:39
작성자

a = [1,1,2,3,5,8,13,24,34,55]

b = [1,1,2,3,4,5,6,7,8,9,10,11,12]

c = []

for i in a:

    for j in b:

        if i==j:

            c.append(i)

        else: 

            0


for u in range(len(c)):

    if c[u] == 1:

        del c[u]

    else:

        0

c.append(1)            

print(c)


이 코드를 치면


IndexError                                Traceback (most recent call last)
<ipython-input-10-da0540243e66> in <module>
      9             0
     10 for u in range(len(c)):
---> 11     if c[u] == 1:
     12         del c[u]
     13     else:

IndexError: list index out of range


이런 오류가 나오는데 왜 그러는지 모르겠습니다 ㅠㅠ
댓글
이전String 관련 질문입니다.2021-04-10
다음짝수 홀수 프로그램2021-04-10