Quiz

Untitled

a = '도봉산'
b = '북한산'
c = '관악산'
e = '금강산'
f = '한라산'
lst = [a, b, c, '주왕산', e, f]

for i in range(len(lst)):
    if('악' in lst[i]):
      print(lst[i])

Untitled

Untitled

lst=[]
for i in range(5):
  a = int(input(f"{i+1}번째 숫자를 입력하시요 : "))
  if a % 2 == 0 :
    lst.append(a)
print(lst)

Untitled

lst = [['도봉산', 100], ['북한산', 120], ['관악산', 110], ['주왕산', 100], ['금강산', 140], ['한라산', 150]]

max = lst[0]
for i in lst:
    if i[1] > max[1]:
        max = i

print(f"가장 높은 산 : {max}")

Untitled

Untitled

lst =[ [1, 2, 'boy'], [True, 3.14], [1, 2, 3, 4, 5, 6]]
for i in lst:
  for j in i:
    print(f'{j}', end=' ')
  print("\\n", end='')

Untitled

Ch04-2 딕셔너리와 반복문

리스트(list)는 '각 요소를 인덱스 기반으로 순서가 있게 저장하는 데이터 형태'입니다.