Friday 18 June 2021

Top 5000 python programs examples with solutions - Part 3

Program 21:

How to write  a program to calculate negative numbers in a list?

list=[1,2,3,4,5,-1,-2,-3,-4,-8]
if 0 not in list:
    list.append(0)
list=sorted(list)
pos=list.index(0)
print(pos)

Read more »

Labels: