Search code examples
pythonstringstring-concatenation

Concatenating strings then printing


print ("Tag Value " + i.tags.get('Name'))

gives me:

  File "./boto_test.py", line 19, in main
    print ("Tag Value" + i.tags.get('Name'))
TypeError: cannot concatenate 'str' and 'NoneType' objects

What is the correct way to do this?


Solution

  • Or just convert whatever you get from i.tags to string:

    print ("Tag Value " + str(i.tags.get('Name')))