๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Algorithm/๋ฐฑ์ค€(BOJ)

[ ํŒŒ์ด์ฌ(python) ] ๋ฐฑ์ค€ 10820 - ๋ฌธ์ž์—ด ๋ถ„์„

by YWTechIT 2021. 6. 17.
728x90

๐Ÿ“ ๋ฐฑ์ค€ 10820 - ๋ฌธ์ž์—ด ๋ถ„์„

๋ฐฑ์ค€ 10820 - ๋ฌธ์ž์—ด ๋ถ„์„


โšก๏ธ ๋‚˜์˜ ํ’€์ด

  1. ๋ฌธ์ž์—ด n๊ฐœ๊ฐ€ ๋ช‡ ๋ฒˆ์งธ๊นŒ์ง€์ธ์ง€ ๋ชจ๋ฅด๊ธฐ ๋•Œ๋ฌธ์— try except๋ฅผ ์‚ฌ์šฉํ–ˆ๋‹ค.(except EOFError)
  2. ์†Œ๋ฌธ์ž: islower(), ๋Œ€๋ฌธ์ž: isupper(), ์ˆซ์ž: isdigit(), ๊ณต๋ฐฑ: else
  3. ๊ฐ count๋ˆ„์ 

 

while True:
try:
lower_case, upper_case, number, blank = 0, 0, 0, 0
for i in input():
if i.islower():
lower_case += 1
elif i.isupper():
upper_case += 1
elif i.isdigit():
number += 1
else:
blank += 1
print(lower_case, upper_case, number, blank)
except EOFError:
break

 

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€