[Baekjoon] 백준 1152번 단어의 개수
(파이썬 Python)
* 문제출처 : 백준 알고리즘 문제
백준 1152번 단어의 개수
1) 문제
2) 풀이 과정
1. 문자열로 주어진다는 점에 착안
2. 공백을 기준으로 단어의 묶음으로 개수 처리
3) 코드
1
2
3
|
str = input().split()
print(len(str))
|
cs |
< < split() 함수 참고 > >
2020/11/02 - [* Language/Python] - [Python] 파이썬 : 문자열 (공백)나누기(split())와 결합(join())
4) 정리 노트
: Input()값으로 The Curious Case of Benjamin Button 주었을 때
1
2
3
4
5
|
str = input().split()
print(str)
# The Curious Case of Benjamin Button
# ['The', 'Curious', 'Case', 'of', 'Benjamin', 'Button']
|
cs |
1
2
3
4
5
|
str = input().split()
print(len(str))
# The Curious Case of Benjamin Butto
# 6
|
cs |
'*Algorithm > Baekjoon' 카테고리의 다른 글
[Baekjoon] 백준 10952번 A+B - 5(파이썬 Python) (0) | 2021.01.13 |
---|---|
[Baekjoon] 백준 2884번 알람 시계(파이썬 Python) (0) | 2021.01.12 |
[Baekjoon] 백준 2588번 곱셈(파이썬 Python) (0) | 2021.01.11 |
[Baekjoon] 백준 2442번 별 찍기 - 5(파이썬 Python) (0) | 2020.11.14 |
[Baekjoon] 백준 5585번 거스름돈(파이썬 Python) (0) | 2020.08.30 |
댓글