물음표 살인마의 개발블로그

알고리즘 문제/CodeWar

Is Integer Array?

BEstyle 2022. 11. 15. 13:24

DESCRIPTION:

Write a function with the signature shown below:

def is_int_array(arr):
    return True
  • returns true / True if every element in an array is an integer or a float with no decimals.
  • returns true / True if array is empty.
  • returns false / False for every other input.

def is_int_array(arr):
    print(arr)
    if arr=="":
        return False
    if arr==None:
        return False
    if len(arr)==0:
        return True
    if None in arr:
        return False
    for i in arr:
        try:
            if int(i)!=i:
                return False
        except:
            return False
    return True

'알고리즘 문제 > CodeWar' 카테고리의 다른 글

Round by 0.5 steps  (0) 2022.11.16
Collatz  (0) 2022.11.15
First Character that repeats  (0) 2022.11.15
Row Of The Odd Triangle  (0) 2022.11.15
Find the Mine!  (0) 2022.11.14