프로그래밍/Python 코테 연습

백준 25304 (영수증) Python / list생성 & For문

하요공간 2022. 9. 24. 14:31

https://www.acmicpc.net/problem/25304

💡 Point 
1.  empty list를 for문 이전에 생성
2. b값을 받아 b만큼 for문 안에서 돌 수있게
3. 매번 iteration할 때마다 자동으로 list안에 값을 붙이기

1. for _ in range(b)

→ for i in ~~쓰지 않고 반복문을 사용할 수 있다!

 

2. list에 값을 붙이려면 ls.append(값)

a = int(input())
b = int(input())
ls=[]
for _ in range(b):
    price,x = map(int,input().split())
    ls.append(price*x)
if sum(ls)==a:
    print('Yes')
else:
    print('No')