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

제목lecture 11 실습 질문2022-04-27 21:25
작성자

#1 

a= [1,2,1,7,5,9,6]

userinput = int(input("enter your number: "))

c = []

for i in range(len(a)):

    if (a[i] < userinput):

        c.append(a[i])

print(c)


#2

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]

a.extend(b)

c= []


for i in a:

    if c.count(i) == 0:

        c.append(i)

print(c)


#질문 : 두 문제 다 a 는 리스트인데, 왜 첫번째 문제에서는 range(len(a)) 를, 두번째 문제에서는 i in a 로 설정하는 것일까요?

차이점이 궁금합니다. 

댓글
이전[re]스트링 메소드 포멧2022-04-28
다음[re]lecture 11 실습 질문2022-04-27