def array_members(arr1):
for i in arr1:
if i in (arr1/2==0):
print(i)
else:
print("No even numbers in array")
arr1 = [2,1,4,7,6,8,11,13]
def array_members(arr1):
for i in arr1:
if i in (arr1/2==0):
print(i)
else:
print("No even numbers in array")
arr1 = [2,1,4,7,6,8,11,13]
It doesn’t give you an error or any result because you define a function
and a list, and then do nothing with them.
You need to call:
array_members(arr1)
after defined the function and list. Then you will see that the function
has many bugs. To help you get started fixing them, here is a hint. To
test for even numbers, you need to check the remainder:
if i % 2 == 0:
# i is an even number