See let’s take a list , say sample_list
sample_list = [1, 5, -9, 6, 7, -7, -2, -4, 2, 3]
Or
sample_list = []
while True:
a = int(raw_input())
if a==0: break
else:sample_list.append(a)
Now, To get the length of list
sample_list_length = len(sample_list)
where len() is a inbuilt function which returns the length of any iterable object like strings,lists,etc.
positive_number = 0
negative_number = 0
for dummy_number in sample_list:
if dummy_number>=0:
positive_number+=1
else:
negative_number+=1
print "There are",positive_number,"positive numbers"
print "There are",negative_number,"negative numbers"
print "There are",sample_list_length,"total numbers"
2
solved Positive and negative numbers