I have this list :
print(new_list)
Output :
[<None></None>]
[<None></None>, <img border="0" data-original-height="855" data-original-width="1885" src="https://1.bp.blogspot.com/-mq2ilVOcyPQ/X70khVD9UaI/AAAAAAAArLw/xC2LggPdcRUTm3aTGpPFYhoM6rDJwbyzACLcBGAsYHQ/s16000-rw/ssc-admit-card.webp"/>]
[<None></None>]
When trying to loop :
for p in new_list:
print(p['src'])
Getting this error :
TypeError: 'NoneType' object is not subscriptable
How to loop and get the items without the error ?
>Solution :
Don’t try to print the Nones, and only print the elements with a 'src' attribute.
for p in new_list:
if p and p['src']:
print(p['src'])