본문 바로가기
프로그래밍 문제/[Python] CheckIO

[CheckIO] Solve All the same

by UltraLowTemp-Physics 2021. 1. 7.
728x90

Problems: py.checkio.org/en/mission/all-the-same/

My solution

from typing import List, Any

def all_the_same(elements: List[Any]) -> bool:
    # your code here
    if len(set(elements)) == 1 or len(set(elements)) == 0: return True 
    else: return False


if __name__ == '__main__':
    print("Example:")
    print(all_the_same([1, 1, 1]))
    
    # These "asserts" are used for self-checking and not for an auto-testing
    assert all_the_same([1, 1, 1]) == True
    assert all_the_same([1, 2, 1]) == False
    assert all_the_same(['a', 'a', 'a']) == True
    assert all_the_same([]) == True
    assert all_the_same([1]) == True
    print("Coding complete? Click 'Check' to earn cool rewards!")
728x90

'프로그래밍 문제 > [Python] CheckIO' 카테고리의 다른 글

[CheckIO] Backward Each Word  (0) 2021.03.10
[Check-IO] Morse Decoder  (0) 2021.03.08
[CheckIO] Solve split list  (0) 2021.01.05
[CheckIO] Sun angle  (0) 2021.01.03
[CheckIO] pawn-brotherhood  (0) 2021.01.02

댓글