본문 바로가기
Algorithm

[구현/문자열] 백준 17863 FYI - 파이썬(Python)

by jangThang 2022. 8. 1.
반응형

백준 온라인 저지

 

[ Contents ]

     

     

    1. 문제 (링크 참조)

     

    17863번: FYI

    In the United States of America, telephone numbers within an area code consist of 7 digits: the prefix number is the first 3 digits and the line number is the last 4 digits. Traditionally, the 555 prefix number has been used to provide directory informatio

    www.acmicpc.net

     

     

     

    2. 문제 풀이

     전화번호가 주어집니다. 앞 자리가 555인지 판별하는 문제입니다.

     

     

     

    3. 코드

    # 입력
    number = input()
    
    # 555인지 확인
    if number[:3] == '555':
        print("YES")
    else:
        print("NO")

     문자열 슬라이싱을 이용해서 앞 3자리까지만 잘라냅니다. 그리고 555인지 판별합니다.

     

    star가 되고나서 Tistory

    반응형

    댓글