-
프로그래머스(Programmers) LEVEL2 - JadenCase 문자열 만들기Algorithm/Problems_Solving 2022. 10. 2. 10:21
''' s.split() vs s.split(" ") ex) s = " 3people unFollowed me" s.split() 는 => ['3people', 'unFollowed', 'me'] s.split(" ")는 => ['', '', '3people', 'unFollowed', 'me'] ''' # 1st def solution(s): s = s.split(" ") return " ".join([strs[0].upper()+strs[1:].lower() if len(strs) > 0 else strs for strs in s]) # 다른사람풀이 def solution(s): s = s.split(" ") for i in range(len(s)): s[i] = s[i][:1].upper() + s[i][1:].lower() # 여기서 s[i][0]하면은 string index out of range 오류남 return ' '.join(s)
'Algorithm > Problems_Solving' 카테고리의 다른 글
프로그래머스(Programmers) LEVEL2 - 전화번호 목록 (0) 2022.10.03 프로그래머스(Programmers) LEVEL2 - 위장 (0) 2022.10.02 프로그래머스(Programmers) LEVEL2 - 행렬의곱셈 (1) 2022.10.01 프로그래머스(Programmers) LEVEL2 - 최댓값과 최솟값 (0) 2022.10.01 백준(BaekJoon)_15657_N과 M(8) (0) 2022.08.27