PS/BOJ
[백준] 대소문자 바꾸기
RUBY_루비
2024. 2. 13. 22:16
출처:: https://www.acmicpc.net/problem/2744
분류::문자열
1. 문제 이해 및 해결과정
2. 풀이방법
1)python
s = input()
ans = ""
for ch in s:
if ch.isupper(): #대문자라면, 소문자로
ans += ch.lower()
else : #소문자라면, 대문자로
ans += ch.upper()
#ans += ch.lower() if ch.isupper() else ch.upper()
print(ans)
2) python
print(input().swapcase())
3. 오답원인
4. 알게된 점
1) islower() : 소문자인지여부
2) upper() : 대문자로 변경
3) swapcase() : 대소문자 변경