![](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FlXCTa%2FbtqTjCL6Ecp%2FoLqiJP6Bkk84kdTVCQJAEk%2Fimg.jpg)
이번 포스팅은 www.acmicpc.net/problem/1152에서 푼 것을 토대로 작성했습니다. 문자열의 여섯 번째 문제인 단어의 개수입니다. 문제 문제 해석 1. 영어 대소문자와 띄어쓰기로 이루어진 문자열을 입력받는다. 2. 공백으로 구분하여 단어의 개수를 출력한다. 3. 단어 맨 앞과 맨 뒤에 공백이 가능하다. Python 코드 s = input() lst = list(s) if s == " ": print(0) elif lst[0] == " " : if lst[len(lst)-1] == " ": print(lst.count(' ')-1) else: print(lst.count(' ')) elif lst[len(lst)-1] == " ": print(lst.count(' ')) else : pri..