반응형
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

+ Recent posts