Is there something wrong with my code

for i, image in enumerate(img_element):
with open(‘inspiration{}.jpg’.format(i),‘wb’) as file:
img_url=image.img.attrs[‘src’]
response=requests.get(img_url)

     file.write(response.content)

and i am getting this error

AttributeError Traceback (most recent call last)
in
1 for i, image in enumerate(img_element):
2 with open(‘inspiration{}.jpg’.format(i),‘wb’) as file:
----> 3 img_url=image.img.attrs[‘src’]
4 response=requests.get(img_url)
5

AttributeError: ‘NoneType’ object has no attribute ‘attrs’

hey @Utkarsh-Madaan-2559055747708288 ,
kindly try printing image.img first.
Your error is saying this to be None . Kindly check that.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.