0

Need a python program to find the number of negative elements in an array.. Anyone help me out..

25th Jul 2017, 4:22 PM
Mohammed Suhail
Mohammed Suhail - avatar
6 odpowiedzi
+ 6
return sum([1 for i in array if i < 0])
25th Jul 2017, 4:27 PM
Maya
Maya - avatar
+ 5
well put it inside a function then (;
27th Jul 2017, 6:34 PM
Maya
Maya - avatar
+ 2
list comprehension is pretty good (;
26th Jul 2017, 1:13 PM
Maya
Maya - avatar
+ 1
Wow that's cool Maya! I didn't know you could create a list by prefixing a for loop.
26th Jul 2017, 2:47 AM
Jim Tully
Jim Tully - avatar
0
tq
26th Jul 2017, 4:06 PM
Mohammed Suhail
Mohammed Suhail - avatar
0
this program showing error as " return outside function"
27th Jul 2017, 2:59 PM
Mohammed Suhail
Mohammed Suhail - avatar