프로그래머스 - LV.0 - 문자열안에 문자열

Jong.-.HANA·2023년 7월 10일

프로그래머스 LV.0

목록 보기
14/50

나의 풀이

def solution(str1, str2):
    answer = 0
    if str2 in str1 :
        return 1
    else:
        return 2 

다른 풀이

def solution(str1, str2):
    return 1 if str2 in str1 else 2
def solution(str1, str2):
    if str1.count(str2):
        return 1
    else:
        return 2

문자열 및 리스트 메서드를 알아두는 것도 좋은 풀이가 될 수 있을 것이다.

Python 메서드를 더욱 연구하자!

profile
존경하는 인물: 현 수원삼성블루윙즈 감독 이정효

0개의 댓글