LV 2: JadenCase 문자열 만들기

ewillwin·2023년 8월 27일
0

문제 링크

LV 2: JadenCase 문자열 만들기


구현 방식

  • 문제에서 하라는 대로 하면 된다

  • string.upper() -> 문자열을 대문자로 변경
  • string.lower() -> 문자열을 소문자로 변경
  • string.isupper() -> 문자가 대문자인지 확인 (문자열의 모든 문자가 대문자인 경우만 True 반환)
  • string.islower() -> 문자가 소문자인지 확인 (문자열의 모든 문자가 소문자인 경우만 True 반환)

코드

def solution(s):
    s = s.split(" ")
    
    result = []
    for word in s:
        if word:
            result.append(word[0].upper() + word[1:].lower())
        else: #공백인 경우
            result.append(word)
        
    return ' '.join(result)
profile
💼 Software Engineer @ LG Electronics | 🎓 SungKyunKwan Univ. CSE

0개의 댓글