Q>
Your mission is to convert the name of a function (a string) from the Python format (for example "my_function_name") into CamelCase ("MyFunctionName"), where the first char of every word is in uppercase and all words are concatenated without any intervening characters.
(당신의 임무는 함수의 이름 (문자열)을 Python 형식 (예 : "my_function_name")에서 CamelCase ( "MyFunctionName")로 변환하는 것입니다. 여기서 모든 단어의 첫 번째 문자는 대문자이고 모든 단어는 개재하는 캐릭터.)
Input: A function name as a string.
(문자열로서의 함수 이름.)
Output: The same string, but in CamelCase.
(CamelCase에서 같은 문자열이지만.)
Example:
to_camel_case("my_function_name") == "MyFunctionName"
to_camel_case("i_phone") == "IPhone"
to_camel_case("this_function_is_empty") == "ThisFunctionIsEmpty"
to_camel_case("name") == "Name"
How it is used: To apply function names in the style in which they are adopted in a specific language
(함수 이름이 특정 언어로 채택 된 스타일로 적용하려면)
(Python, JavaScript, etc.).
Precondition: 0 < len(string) <= 100
Input data won't contain any numbers.
A>
def to_camel_case(name):
#replace this for solution
#title : 모든 글자에 앞부분을 대문자로 변경
return name.title().replace('_', '')
if __name__ == '__main__':
print("Example:")
print(to_camel_case('name'))
#These "asserts" using only for self-checking and not necessary for auto-testing
assert to_camel_case("my_function_name") == "MyFunctionName"
assert to_camel_case("i_phone") == "IPhone"
assert to_camel_case("this_function_is_empty") == "ThisFunctionIsEmpty"
assert to_camel_case("name") == "Name"
print("Coding complete? Click 'Check' to earn cool rewards!")
O>
Example:
Name
Coding complete? Click 'Check' to earn cool rewards!
Process finished with exit code 0
S>
'Python_Matter > Solve' 카테고리의 다른 글
Python Learn the basics Quiz 88 (0) | 2019.06.21 |
---|---|
Python Learn the basics Quiz 87 (0) | 2019.06.21 |
Python Learn the basics Quiz 85 (0) | 2019.06.21 |
Python Learn the basics Quiz 84 (0) | 2019.06.21 |
Python Learn the basics Quiz 83 (0) | 2019.06.21 |