-
Notifications
You must be signed in to change notification settings - Fork 1
/
061_Is every value in the array an array.py
69 lines (44 loc) · 1.2 KB
/
061_Is every value in the array an array.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
"""
Codewars Coding Challenge
Day 61/366
Level 7kyu
Is every value in the array an array?
Is every value in the array an array?
This should only test the second array dimension of the array. The values of the nested arrays don't have to be arrays.
Examples:
[[1],[2]] => true
['1','2'] => false
[{1:1},{2:2}] => false
def arr_check(arr):
return True
https://www.codewars.com/kata/582c81d982a0a65424000201/train/python
"""
# My Solutions
def arr_check(arr):
for i in arr:
if not isinstance(i, list):
return False
return True
# Test
print(arr_check([[1], [2]]))
print(arr_check(['1', '2']))
"""
Sample Tests
import codewars_test as test
from solution import arr_check
@test.describe("Fixed Tests")
def fixed_tests():
@test.it('Basic Test Cases')
def basic_test_cases():
test.assert_equals(arr_check([]), True)
test.assert_equals(arr_check([['string']]), True)
test.assert_equals(arr_check([[], {}]), False)
test.assert_equals(arr_check([[1], [2], [3]]), True)
test.assert_equals(arr_check(["A", "R", "R", "A", "Y"]), False)
"""
"""
Solutions From Codewars
=1=
def arr_check(arr):
return all(type(i) == list for i in arr)
"""