Coding/Python

[python]문자열 find, startswith, endswith

후__아 2024. 4. 21. 12:06

※ str.endswith(값, start, end)

str의 start, end 위치 내에서 '값'으로 해당 문자열이 끝나는지 확인

# 프로그래머스 접미사 확인
def solution(my_string, is_suffix):
    return 1 if f in [s[i:] for i in range(len(s))] else 0 

    # 다른 사람 풀이
    return int(my_string.endswith(is_suffix))

'Coding > Python' 카테고리의 다른 글

[python]range  (0) 2024.04.24
[python]list comprehension, if-elif-else  (0) 2024.04.24
[python]리스트 sort(key, reverse), sorted()  (0) 2024.04.21
[python]문자열 reverse, reversed  (0) 2024.04.19
[python]반복문  (0) 2024.04.19