Error with concatenating list to string in Python
Question: I am trying to pass class element to method. Element is formed dynamically
inserting current time in it. Mine class looks something like this:

    
    
    class MineContact(dict):
        def __init__(self, **kwargs):
            # set your default values
            import time
            curr_time = repr(time.time()).replace('.', '') 
            self['givenName'] = ['name%s' % curr_time[10:]]
            ...
    

So, I create object of this class and now I want to insert it as method
argument:

    
    
        contact = MineContact()
        extra_text = "-%d" % (self.iteration)
        new_contact.insert_given_name(contact.givenName + extra_text)
    

When I run this script, I get this type of error:

> TypeError: can only concatenate list (not "str") to list

So, does anyone knows where am I getting it wrong?


Answer: `givenName` seems to be a list. You can append another list like this:

    
    
    new_contact.insert_given_name(contact.givenName + [extra_text])
    

