The problem is that you reset dare zero at the beginning of each iteration and clear c.
You need to move the initialization code outside the loop.
In doing so, you can simplify the whole cycle as follows:
a = [',', 'hello',',', 'pear']
c = []
for b in a:
if b == ',':
c.append(b)
print c
Now notice that such code expresses itself very well as an expression:
a = [',', 'hello',',', 'pear']
c = [b for b in a if b == ',']
print c
source
share