title: How do I convert a text corpus into a string? gettign error code: expected str instance, list found
body: <p><a href="https://i.stack.imgur.com/Dv06W.png" rel="nofollow noreferrer">Code</a></p>
  <p>Getting the error code: word_frequency = Counter(&quot; &quot;.join(description_list).split()).most_common(10)
  TypeError: sequence item 0: expected str instance, list found</p>
  <p>What am I doing wrong? I have attempted to convert the text corpus into string to no avail. How do I bypass this error? Is there something fundamentally wrong with my code?</p>
  <p>CODE:</p>
  <pre><code>from urllib.request import urlopen
  from bs4 import BeautifulSoup
  import pprint
  from re import X
  import string
  from tokenize import Token
  from collections import Counter
  import matplotlib.pyplot as plt
  import pandas as pd
  
  url = &quot;https://www.bbc.com/news/world-us-canada-61294585&quot;
  html = urlopen(url).read()
  soup = BeautifulSoup(html, features=&quot;html.parser&quot;)
  
  # kill all script and style elements
  for script in soup([&quot;script&quot;, &quot;style&quot;]):
      script.extract()   
  
  # get text
  text = soup.get_text()
  
  document = text 
  
  text_corpus = [text]
  
  # Create a set of frequent words
  stoplist = set('for a of the and to in'.split(' '))
  # Lowercase each document, split it by white space and filter out stopwords
  texts = [[word for word in document.lower().split() if word not in stoplist]
           for document in text_corpus]
  
  # Count word frequencies
  from collections import defaultdict
  frequency = defaultdict(int)
  for text in texts:
      for token in text:
          frequency[token] += 1
  
  # Only keep words that appear more than once
  processed_corpus = [[token for token in text if frequency[token] &gt; 1] for text in texts]
  pprint.pprint(processed_corpus)
  
  data = {
      &quot;description&quot;: [text_corpus]
      }
  
  df = pd.DataFrame(data)
  description_list = df['description'].values.tolist()
  
  text = ','.join(map(str, description_list))
  word_frequency = Counter(&quot; &quot;.join(description_list).split()).most_common(10)
  
  # `most_common` returns a list of (word, count) tuples
  words = [word for word, _ in word_frequency]
  counts = [counts for _, counts in word_frequency]
  
  plt.bar(words, counts)
  plt.title(&quot;10 most frequent tokens in description&quot;)
  plt.ylabel(&quot;Frequency&quot;)
  plt.xlabel(&quot;Words&quot;)
  plt.show()
  </code></pre>