[Solved] Problem with can only concatenate str (not “NoneType”) to str


The problem is, sizes doesn’t return anything. print does not return values, it just prints. You’d need to do something like:

acc = ""
for span in Size:
   acc += span.text.replace('EU:','').strip()  # Concatenate the strings together
return acc

There are also more efficient ways of doing this using a list comprehension/generator expression and join:

return "".join(span.text.replace('EU:','').strip() for span in Size)

But that’s getting a little more complicated.

7

solved Problem with can only concatenate str (not “NoneType”) to str