https://school.programmers.co.kr/learn/courses/30/lessons/120893
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
이 문제를 풀기 위해 유니코드를 알아야 했다.
ord(문자)
하나의 문자를 받으면 유니코드 정수를 반환한다.
https://docs.python.org/ko/3/library/functions.html?highlight=ord#ord
Built-in Functions
The Python interpreter has a number of functions and types built into it that are always available. They are listed here in alphabetical order.,,,, Built-in Functions,,, A, abs(), aiter(), all(), a...
docs.python.org
print(ord(a)) # 97
print(ord(A)) # 65
chr(i)
유니코드 정수 i인 문자를 나타내는 문자열을 반환한다.
https://docs.python.org/ko/3/library/functions.html?highlight=ord#chr
Built-in Functions
The Python interpreter has a number of functions and types built into it that are always available. They are listed here in alphabetical order.,,,, Built-in Functions,,, A, abs(), aiter(), all(), a...
docs.python.org
print(chr(97)) # a
print(chr(65)) # A
위 두개를 알면
def solution(my_string):
answer = ''
for i in my_string:
if ord(i) >= 97:
answer += chr(ord(i) - 32)
else:
answer += chr(ord(i) + 32)
return answer
이렇게 풀 수 있따.
그런데 다른 분은....
swapcase()
https://docs.python.org/ko/3/library/stdtypes.html?highlight=swapcase#str.swapcase
Built-in Types
The following sections describe the standard types that are built into the interpreter. The principal built-in types are numerics, sequences, mappings, classes, instances and exceptions. Some colle...
docs.python.org
를 사용하여
def solution(my_string):
return my_string.swapcase()
간단하게 풀으신 분도 계셨다....
좀 더 찾아보니
대문자로 바꿔주는
upper()
https://docs.python.org/ko/3/library/stdtypes.html?highlight=upper#str.upper
Built-in Types
The following sections describe the standard types that are built into the interpreter. The principal built-in types are numerics, sequences, mappings, classes, instances and exceptions. Some colle...
docs.python.org
소문자로 바꿔주는
lower()
https://docs.python.org/ko/3/library/stdtypes.html?highlight=lower#str.lower
Built-in Types
The following sections describe the standard types that are built into the interpreter. The principal built-in types are numerics, sequences, mappings, classes, instances and exceptions. Some colle...
docs.python.org
이라는 것도 알게 되었다.
TIL230411 오늘 점검 후 알게 된 것
for문은 정해진 루프 while 정해지지 않는 루프 for문은 왠만하면 다 돌릴 수 있다. num.list 1이란 것을 있는 지 없는지 o, x if문 in넣어서 사용 가능... try exept에 else에 넣을 수 있음 fainally 사용자에게
beolog.tistory.com
댓글