I have a list which has elements of type int and str. I need to copy the int elements to another list. I tried a list comprehension which is not working. My equivalent loop is working.
input = ['a',1,'b','c',2,3,'c','d']
output = []
[output.append(a) for a in input if type(a) == int]
[None, None, None]
same logic in loop works.
output = []
for a in input:
if type(a) == int:
output.append(a)
print(output)
[1,2,3,]
Can I know what made the difference.