Write a program that accepts a list of numbers separated by space. Use any() function
Sample output 1:
Enter numbers separated by space: 0 0 0 0 0 0
All input are zero
Sample output 2:
Enter numbers separated by space: 0 0 0 0 0 0 1
Not all inputs are zero
def zero(arr):
nozero = 0
for i in range(len(arr)):
if arr[i] != 0:
nozero = 1
if nozero == 1:
mess = 'Not all inputs are zero'
else:
mess = 'All input are zero'
return mess
print('Enter list of numbers separated by space: ', end='')
A = input().split(' ')
for i in range(len(A)):
A[i] = int(A[i])
print(zero(A))
Comments
Leave a comment