22-05-25 TIL

강지훈·2022년 5월 25일
0

파이썬 replace 함수와
count 함수에 대해서...

  • replace는 문자열을 변경하는 함수이다

replace(x,y)
x를 y로 바꿔준다

st='hello world'
print(st)

st=st.replace('hello','hi')

print(st)

hi world가 출력된다.

*count 함수는 문자열에 쓰인다
count(x) x가 몇번 쓰이냐

a=hello world
a.count('e')

st='hello world'
print(st.count('l'))
결과: 3이나옴

profile
never stop

0개의 댓글