sWAP cASE
문제 출처 : https://www.hackerrank.com/challenges/swap-case/problem?isFullScreen=true
sWAP cASE | HackerRank
Swap the letter cases of a given string.
www.hackerrank.com
<Problem>
대문자는 소문자로, 소문자는 대문자로 전환해주는 함수를 작성해라.
<Solution>
def swap_case(s):
x = str(s.swapcase())
return x
if __name__ == '__main__':
s = input()
result = swap_case(s)
print(result)
# swapcase() : 대문자는 소문자로, 소문자는 대문자로 전환해주는 함수
String Split and Join
문제 출처 : https://www.hackerrank.com/challenges/python-string-split-and-join/problem?isFullScreen=true
String Split and Join | HackerRank
Use Python's split and join methods on the input string.
www.hackerrank.com
<Problem>
공백(" ") 을 기준으로 문자열을 분할한 뒤 하이픈(-)으로 문자열을 결합하는 함수를 작성해라.
<Solution>
def split_and_join(line):
line = line.split(" ")
line = "-".join(line)
return line
if __name__ == '__main__':
line = input()
result = split_and_join(line)
print(result)
# 문자열.split(구분자) : 구분자를 기준으로 문자열을 분할하는 함수
# 특정문자열.join(리스트) : 특정문자열을 사용하여 문자열을 결합하는 함수
What's Your Name?
문제 출처 : https://www.hackerrank.com/challenges/whats-your-name/problem?isFullScreen=true
What's Your Name? | HackerRank
Python string practice: Print your name in the console.
www.hackerrank.com
<Problem>
사람의 이름과 성을 입력받아 문자열을 출력하는 함수를 작성해라.
출력해야 할 문자열은 다음과 같다.
Hello firstname lastname! You just delved into python.
<Solution>
def print_full_name(first, last):
print("Hello {0} {1}! You just delved into python.".format(first, last))
if __name__ == '__main__':
first_name = input()
last_name = input()
print_full_name(first_name, last_name)
'HackerRank > Python' 카테고리의 다른 글
[Python] Strings (2) (0) | 2022.05.13 |
---|---|
[Python] Basic Data Types (2) (0) | 2022.04.14 |
[Python] Basic Data Types (1) (0) | 2022.04.13 |
[Python] Introduction (0) | 2022.03.30 |