Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 파이썬
- SW Expert Academy
- leetcode
- gs25
- PYTHON
- Git
- 자연어처리
- 캐치카페
- Baekjoon
- ubuntu
- 우분투
- hackerrank
- ChatGPT
- Kaggle
- 더현대서울 맛집
- 데이콘
- 맥북
- Docker
- 편스토랑
- Real or Not? NLP with Disaster Tweets
- 백준
- programmers
- 코로나19
- 편스토랑 우승상품
- github
- 금융문자분석경진대회
- 프로그래머스
- dacon
- AI 경진대회
- 프로그래머스 파이썬
Archives
- Today
- Total
솜씨좋은장씨
[BaekJoon] 2386번 : 도비의 영어 공부 (Python) 본문
728x90
반응형
코딩 1일 1문제! 오늘의 문제는 백준의 도비의 영어 공부 입니다.
👨🏻💻 코드 ( Solution )
from collections import Counter
def count_word(sentence, word):
count = 0
sentence = list(sentence)
cnt = Counter(sentence)
if word in cnt:
count = cnt[word]
return count
def dobbys_english_study(study_list):
answer_list = []
for study in study_list:
count = count_word(sentence=study[1], word=study[0])
answer = f"{study[0]} {count}"
answer_list.append(answer)
return answer_list
if __name__ == "__main__":
study_list = []
while True:
study = input()
if study == "#":
break
study = study.split()
word, sentence = study[0], " ".join(study[1:]).lower()
study_list.append((word, sentence))
answer_list = dobbys_english_study(study_list=study_list)
for answer in answer_list:
print(answer)
'Programming > 코딩 1일 1문제' 카테고리의 다른 글
[BaekJoon] 9506번 : 모든 약수의 합 (Python) (0) | 2022.08.05 |
---|---|
[BaekJoon] 4096번 : 팰린드로미터 (Python) (0) | 2022.08.02 |
[BaekJoon] 1673번 : 치킨 쿠폰 (Python) (0) | 2022.07.31 |
[BaekJoon] 11282번 : 한글 (Python) (0) | 2022.07.30 |
[BaekJoon] 11283번 : 한글 2 (Python) (0) | 2022.07.29 |
Comments