adierebel / Check list using loop

20 Jul 2018 at 03:53

1 def check_list(List, CheckValue):
2 Result = True
3 # Loop
4 for Item in List:
5 # Check
6 if not Item == CheckValue:
7 Result = False
8 return Result
9
10 #
11 # Example
12 #
13
14 ListA = [1.0, 0.0, 0.0]
15 CheckA = 0.0
16
17 print(check_list(ListA, CheckA))
18 # False
19
20 ListB = [0.0, 0.0, 0.0]
21 CheckB = 0.0
22
23 print(check_list(ListB, CheckB))
24 # True

Comments (0)