Jaden Case

๋ฌธ์ œ

๋ชจ๋“  ๋‹จ์–ด์˜ ์ฒซ ๋ฌธ์ž๊ฐ€ ๋Œ€๋ฌธ์ž์ด๊ณ  ์ด์™ธ์˜ ์•ŒํŒŒ๋ฒณ์€ ์†Œ๋ฌธ์ž์ธ ๋ฌธ์ž์—ด์ด๋‹ค. ๋ฌธ์ž์—ด s๊ฐ€ ์ฃผ์–ด์กŒ์„๋•Œ s๋ฅผ jaden case๋กœ ๋ฐ”๊พผ๋‹ค์Œ ๋ฌธ์ž์—ด์„ ๋ฆฌํ„ดํ•˜์‹œ์˜ค

ํ’€์ด

  • capitalize๊ฐ€ ์žˆ๋Š” ๊ฑธ ๋ชฐ๋ž์„ ๋•Œ -> ๋Ÿฐํƒ€์ž„ ์—๋Ÿฌ๋‚จ
    def solution(s)
      splt = s.split(' ')
      for c in splt:
          if not c[0].isalpha():
              word = c.lower()
          else:
              word = c[0].upper() + c[1:].lower()
          strs.append(word)
      return ' '.join(strs)
    
  • ์•Œ๊ณ ๋‚œ ํ›„ -> ์—๋Ÿฌ ์•ˆ๋‚จ
    def solution(s):
      return ' '.join([word.capitalize() if word[0].isalpha() else word.lower() for word in s.split(' ')])
    

Leave a comment