KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
>>> aList = [] >>> aList += 'chicken' >>> aList ['c', 'h', 'i', 'c', 'k', 'e', 'n'] >>> aList = aList + 'hello' Traceback (most recent call last): File "<pyshell#16>", line 1, in <module> aList = aList + 'hello' TypeError: can only concatenate list (not "str") to list I don't get why doing a list += (something) and list = list + (something) does different things. Also, why does += split the string up into characters to be inserted into the list?
Tags (comma-separated)
Save Edits
Cancel