Muscardinus 2020. 9. 7. 22:40
728x90

www.acmicpc.net/problem/10820

 

10820번: 문자열 분석

문자열 N개가 주어진다. 이때, 문자열에 포함되어 있는 소문자, 대문자, 숫자, 공백의 개수를 구하는 프로그램을 작성하시오. 각 문자열은 알파벳 소문자, 대문자, 숫자, 공백으로만 이루어져 있

www.acmicpc.net

while 1 :
  try:
    str=input()
  except:
    break
  str=list(str)
  small=0
  big=0
  num=0
  space=0
  for check in str:
    if check >='a' and check <='z':
      small+=1
    if check >='A' and check <='Z':
      big+=1
    if check >='0' and check <='9':
      num+=1
    if check == ' ':
      space+=1
  print(small,big,num,space)
728x90