[Answered ]-Python development โ€“ elementtree XML and string operations

2๐Ÿ‘

โœ…

You get a tuple because you supply a tuple (the parentheses) as the default return value for url.get(). Supply an empty string, and you can use its .endswith() method. Also note that the element itself has a get() method to retrieve attribute values (you do not have to go via .attrib). Example:

if i.get('Href', '').endswith('.jpg'):
    result.append(i.attrib)
๐Ÿ‘คSteven

Leave a comment