I am working with heart rate data and I want to strip away the numbers that the heart rate never reached for that day.
Some code:
result_list = [
'0 instances of 44 bpm',
'0 instances of 45 bpm',
'10 instances of 46 bpm',
'22 instances of 47 bpm',
'354 instances of 65 bpm',
'20 instances of 145 bpm'
]
strip_zero = [x for x in result_list if not '0 instances' in x]
print(strip_zero)
Result:
['22 instances of 47 bpm', '354 instances of 65 bpm']
if I use this: '\'0 instances'
instead of this: '0 instances'
none of the 0 instances are removed