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

제목Loof1 실습 질문2019-10-14 20:20
작성자

a=[1,2,1,8,9,4,2,5,1,3]

b=int(input("Decide your number:"))

c=[]

for x in a:

    if x<b:

        c.append(x)

    else:

        print("")

print(c)  


이렇게 입력하면 

Decide your number:5

[1, 2, 1, 4, 2, 1, 3] 라고 잘나오는데 
a=[1,2,1,8,9,4,2,5,1,3]
b=int(input("Decide your number:"))
for x in a:
    c=[]
    if x<b:
        c.append(x)
    else:
        print("")
print(c)
Decide your number:4
이렇게 하면 그냥 [3]  이라고만 나옵니다. 이유좀 알려주시면 감사드리겠습니다.
댓글
이전list in list 실습파일 질문입니다.2019-10-14
다음구구단 질문2019-10-14