CMU Coding Bootcamp
at 74d84bf6e8a67ed3b6ea7ef669b0a5cd3c8beb2e 24 lines 572 B view raw
1from typing import List 2 3 4def isRectangular(L: List[List[int]]) -> bool: 5 """Check if the length of each row is equal to the length of the first row.""" 6 return all(len(row) == len(L[0]) for row in L) 7 8 9def testIsRectangular(): 10 print("Testing isRectangular()...", end="") 11 L = [[1, 2, 3], [4, 5, 6]] 12 assert isRectangular(L) == True 13 L = [[1, 2], [4, 5, 6]] 14 assert isRectangular(L) == False 15 L = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]] 16 assert isRectangular(L) == True 17 print("Passed!") 18 19 20def main(): 21 testIsRectangular() 22 23 24main()