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

제목Lecture13-2_DataCollectionTypes2 질문2021-11-04 17:05
작성자

observation_file = open('extxt.txt','r')

bird_count=[]

for line in observation_file:

    bird=line.strip()

    found=False

    for entry in bird_count:

        if entry[0]==bird:

            entry[1]+=1

            found=True;

    if not found:

        bird_count.append([bird,1])

print(bird_count)


27:13쯤 내용으로, 딕셔너리 이전에 list로 정리하는 방식입니다.
제가 궁금한 것은,

for entry in bird_count:

        if entry[0]==bird:

            entry[1]+=1

            found=True;


여기서 entry가 list 인것을 정의하지 않았는데 처음에 어떻게 entry[0] == bird임을 확인하나요?


댓글
이전[re]file_2 강의 예제2021-11-06
다음[re]Lecture13-2_DataCollectionTypes2 질문2021-11-04