Current post is on how to recover from AttributeError: 'list' object has no attribute 'join'.
Started working on python and got struck in 'JOIN' function?
Got the "AttributeError: 'list' object has no attribute 'join' " error when trying to JOIN list in Python?
Just change the list and argument place.
Reason is we are wired to think like object.some_function arguments but here its like argument.some_function object(s)
List JOIN in Python:
mypythonlist = ['ListElement1', 'ListElement2']
mypytonlist.join('-') #Incorrect Usage which gave the AttributeError
'-'.join(mypythonlist) #Correct Usage
# It will return 'ListElement1-ListElement2'
For detailed information refer to 'JOIN' function post
Hope this post saved your time.
Appreciate your feedback via comments. Thanks.
No comments:
Post a Comment