From cc90dc2adacb24d9965db20845a37a775d52e78b Mon Sep 17 00:00:00 2001 From: huisuu Date: Thu, 22 Aug 2024 21:56:39 +0900 Subject: [PATCH] 36.py --- HSKIM/31to40/36.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 HSKIM/31to40/36.py diff --git a/HSKIM/31to40/36.py b/HSKIM/31to40/36.py new file mode 100644 index 0000000..8c20e10 --- /dev/null +++ b/HSKIM/31to40/36.py @@ -0,0 +1,12 @@ +def solution(phone_book): + # 사전 순으로 앞서는 것을 앞으로 정렬 + phone_book.sort( ) + + for i in range(len(phone_book) - 1): + # startswith 는 현재 문자열이 사용자가 지정하는 특정 문자로 시작하는지 확인하는 함수 + if phone_book[i + 1].startswith(phone_book[i]): + return False + return True + +phone_book = ["119", "97674223", "1195524421"] +print(solution(phone_book)) \ No newline at end of file