강의

멘토링

커뮤니티

Inflearn Community Q&A

wannabeing's profile image
wannabeing

asked

Introduction to Python Algorithm Problem Solving (Coding Test Preparation)

9. Anigram dictionary improvement code

아니그램 질문입니다!

Written on

·

224

0

a = input()
b = input()

c = dict()

for x in a:
    c[x] = c.get(x, 0) + 1
for x in b:
    c[x] = c.get(x, 0) -1

for val in c.values():
    if val != 0:
        print("NO")
        break
else:
    print("YES")

선생님 안녕하세요!

위 코드처럼 각 밸류의 값 중에 0이 아닌 값이 있다면

바로 No 출력하는것도 괜찮을까요?

돌려봤을 때 문제 없었습니다!

 

항상 감사합니다!

python코테 준비 같이 해요!

Answer 1

1

codingcamp님의 프로필 이미지
codingcamp
Instructor

안녕하세요^^

네. 좋은 코드입니다.

wannabeing's profile image
wannabeing

asked

Ask a question