Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jennyonjourney/6be195c5f36802f6c889f4dfe52b1b22 to your computer and use it in GitHub Desktop.
Save jennyonjourney/6be195c5f36802f6c889f4dfe52b1b22 to your computer and use it in GitHub Desktop.
Python - hit practice2
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