Created
March 25, 2018 01:42
-
-
Save jennyonjourney/6be195c5f36802f6c889f4dfe52b1b22 to your computer and use it in GitHub Desktop.
Python - hit practice2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hit = [22,24,25,27,21,22,23,25,27,22,24,27,22] | |
hh = {} | |
# i번째가 아니라 hit의 'i'key라는 의미 | |
# hh[i]는 hh의 딕셔너리의 i key라는 의미 | |
# cnt 1 인상태인데 만약 i가 hh안에 있으면 cnt더하세요, 카운트 수가 올라가겠지. | |
for i in hit: | |
cnt = 1 | |
if i in hh: | |
cnt += hh[i] | |
hh[i] = cnt | |
print(hh) | |
for i in hh: | |
print(i, ":", hh[i]) | |
print('-------------------') | |
for i in hit: | |
cnt = 1 | |
hh[i] = cnt | |
if i in hh: | |
cnt += hh[i] | |
print(hh) | |
for i in hh: | |
print(i, ":", hh[i]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment