Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- INT
- 자료형
- 알고리즘
- 데이터타입
- 백준
- 리스트
- 웹 서버
- aws
- 짝수
- 온프레미스
- algorithm
- valueof
- IaaS
- 홀수
- Python
- 11652
- level1
- SaaS
- 유클리드 호제법
- 최대공배수
- 11004
- 최대공약수
- parseInt
- 2진수
- IntelliJ
- 프로그래머스
- java
- 프로젝트 생성
- PaaS
- 문자열 숫자 변환
Archives
- Today
- Total
Ga0Lee
[알고리즘] 문자열 분석 백준 10820 (Python) 본문
ASCII CODE 값
'A' ~ 'Z' : 65 ~ 90
'a' ~ 'z' : 97 ~ 122
0 ~ 9 : 48 ~ 57
코드
import sys
while True:
str = sys.stdin.readline().rstrip("\n")
if not str : break
alphabet =[0] * 4
for i in str:
if ord(i) > 96 and ord(i) < 123 :
alphabet[0] += 1
elif ord(i) > 64 and ord(i) < 91 :
alphabet[1] += 1
elif ord(i) > 47 and ord(i) < 58 :
alphabet[2] += 1
elif i == " " :
alphabet[3] += 1
print(*alphabet)
str = sys.stdin.readline().rstrip("\n")
개행을 무시하기 위해 rstrip("\n")
if not str : break
처음에 반복문 탈출 조건을 추가하지 않았더니 출력초과가 나왔다. 그래서 반복문 탈출 조건을 추가하여 문제를 풀 수 있었다.
입출력
'Algorithm' 카테고리의 다른 글
[알고리즘] ROT13 백준 11655 (Python) (0) | 2022.01.17 |
---|---|
[알고리즘] 단어 길이 재기 백준 2743 (Python) (0) | 2022.01.17 |
[알고리즘] 알파벳 찾기 백준 10809 (Python) (0) | 2022.01.17 |
[알고리즘] 알파벳 개수 백준 10808 (Python) (0) | 2022.01.17 |
[알고리즘] 덱 백준 10866 (Python) (0) | 2022.01.16 |