Issue
I have below two doubts
1)I am trying to build a wordcloud and for doing that am defining a variable a=[ ] but it throws error but if I define it as a='' it works well. Please tell me what is the difference between them?
- I am using below two for loops but both of them show difference output whereas I expect them to show the same? What is the difference between them.
a)
allwords=[]
for i in data['Url']:
allwords+= ' '.join(i)
b) all_words = ' '.join([text for text in data['Url']])
Solution
About item A
There is an error in your code. To add an element to a list, use the append method:
allwords=[]
for i in data['Url']:
allwords.append(' '.join(i))
Use += to concatenate the string or append method to add an item to a list.
About item B
This works properly because is an attribution.
Answered By - Lucas Moreira Answer Checked By - David Goodson (sql.easybugfix Volunteer)
Post a Comment
Post a Comment