본문 바로가기

Python(알고리즘,문제풀이)/프로그래머스(입문100제)

코딩테스트입문 / 로그인 성공?

728x90

📚문제

출처 : 프로그래머스 / 로그인 성공?(https://school.programmers.co.kr/learn/courses/30/lessons/120883)

📝풀이

def solution(id_pw, db):
    
    result = []
    
    for d in db:
        if id_pw[0]==d[0] and id_pw[1]==d[1]:
            result.append('login')
        elif id_pw[0]==d[0] and id_pw[1]!=d[1]:
            result.append('wrong pw')
        elif id_pw[0]!=d[0] and id_pw[1]!=d[1]:
            result.append('fail')
    
    if 'login' in result:
        return 'login'
    elif 'wrong pw' in result:
        return 'wrong pw'
    else:
        return 'fail'

상대적으로 다른 문제들이 어려워서 조금 쉽게 푼 느낌이다..

이제 프로그래머스 입문 문제들도 어려워진다..!

이렇게 조금씩 해나가면서 많이 틀리고 많이 배우면서 실력 쌓아올리자

728x90