#메서드 : 특정 자료형에 .을 찍어서 사용하는 전용 함수
'''
문자열 메서드
lower() 전부 소문자로 만든다
upper() 전부 대문자로 만든다
find('a') 문자a가 처음 나오는 인덱스를 출력, 없으면 -1 출력
replace(a, b) a를 b로 바꾼다
split(a) a를 기준으로 나눈다
'''
text = 'Python is Fun'
print(text.lower())
print(text.upper())
print(text.find('Is'))
print(text.replace(' ', '-'))
print(text.split()) #기본 단위가 ' '

'''
😺 문제: 고양이의 자기소개
고양이 나비가 자기소개를 했어요.
t = 'Hello My name is Nabi'
이 문장을 가지고 아래 문제를 풀어보세요!
'''
t = 'Hello My name is Nabi'
#모든 글자를 대문자로 바꿔 출력해보세요.
print(t.upper())
#"name"이라는 단어는 몇 번째에서 시작하나요?
print(t.find('name'))
#문장에서 띄어쓰기(' ')를 물결(~)로 바꿔보세요.
print(t.replace(' ', '~'))
#문장을 띄어쓰기를 기준으로 단어로 나눠서 리스트로 만들어보세요.
a = t.split()
print(a[2])

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: