muchmanymoney / homework

0 stars 0 forks source link

for문을 list comprehension 스타일로 짜는걸 연습해보세요 #12

Open ej31 opened 1 year ago

ej31 commented 1 year ago

https://github.com/muchmanymoney/homework/blob/868e1b743111100b8893fbd07c57b8a1626dbe36/num_list_class.py#L14C1-L16C38

이 부분은 한 줄로 요약이 가능해집니다.

        # before
        for num in self.num_list:
            if num % 2 == 0:
                even_list.append(num)

        # after
        even_list = [num for num in self.num_list if num % 2 == 0]