Skip to content
Sign upLog in
← Back to Community

Guys please help to count

Profile icon
HussainO

Guys im new to programming,I want to know how many twelves in list=[1,2,3,4,5,6,7,8,9,10,11],
1.add two numbers if that number gets value as 12,please add count as 1,loop over the list i want to know how many 12's in the particular list
This is my code....
#This program is used to count how many number add to get 12
def add(list1):

for i in list1:
for j in list1:
c=i+j
count1=1
if c==4:
count1+=1

print(count1)

list1=[1,2,3,4,5,6,7,8,9,10,11]
print(add(list1))

Voters
Profile icon
gyprts
Profile icon
HussainO
Comments
hotnewtop
Profile icon
CodeLongAndPros

What do you mean? You want to find the number of times an int is in list foo?
foo.count(1)

Profile icon
HussainO

@CodeLongAndPros
thanks for reply bro i want if u get addition of two numbers get 12 please add 1 in count
(11+1)=12 and (10+2)=12
this is example bro add 1 if u get 12

Profile icon
CodeLongAndPros

@HussainO
Ok, so I see what you're trying to do, what do you need help with?

Profile icon
HussainO

@CodeLongAndPros
(1+11)
(2+10)
(3+9)
(4+8)
(5+7)
(6+6)
(7+5)
(8+4)
(9+3)
(10+2)
(11+1)
Above all the values are given adding value as 12
there are 11 number of twelve in the above method
i want this addition method in coding
Thats all......bro