반응형
SMALL
문제
#!/bin/python3
import math
import os
import random
import re
import sys
# Complete the solve function below.
def solve(s):
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
s = input()
result = solve(s)
fptr.write(result + '\n')
fptr.close()
기본 코드
주어지는 문장의 첫 글자를
대문자로 전환
#!/bin/python3
import math
import os
import random
import re
import sys
import string
# Complete the solve function below.
def solve(s):
s = string.capwords(s, ' ')
return s
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
s = input()
result = solve(s)
fptr.write(result + '\n')
fptr.close()
이렇게 풀긴 했지만
몇몇 모범 답안 추가로 올립니다..
더보기
#!/bin/python3
import math
import os
import random
import re
import sys
# Complete the solve function below.
def solve(s):
s=s.split()
for i in range(len(s)):
s[i]=s[i].title()
return " ".join(s)
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
s = input()
result = solve(s)
fptr.write(result + '\n')
fptr.close()
#!/bin/python3
import math
import os
import random
import re
import sys
# Complete the solve function below.
def solve(s):
s = s.split(" ")
return(" ".join(i.capitalize() for i in s))
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
s = input()
result = solve(s)
fptr.write(result + '\n')
fptr.close()
반응형
LIST
'IT & 영상관련 > 파이썬python' 카테고리의 다른 글
HackerRank] .permutations() 순열 (저장용) (0) | 2020.08.05 |
---|---|
HackerRank] itertools.product() 리스트 간 곱하기 (저장용) (0) | 2020.08.04 |
python]hackerRank] Alphabet Rangoli (다시보기) (저장용) (0) | 2020.08.02 |
python]hackerRank] String Formatting 진수변환, 간격(저장용) (0) | 2020.08.01 |
python]hackerRank] Text Alignment (저장용) (0) | 2020.07.31 |