title: How to find a random word from a word list that starts with a certain character?
body: <p>I am trying to retrieve a word from a word list that starts with a certain letter. This letter is specified through a variable char. The word list Is taken from an online source using requests. the code below does not work properly.</p>
  <pre><code>def randomword(char):
      # use char to find a word from the dictionary 
      print(&quot;The computer is attempting to find a word&quot;)
      url = &quot;http://www.mieliestronk.com/corncob_lowercase.txt&quot;
      res = requests.get(url)
      text = res.text 
      words = [idx for idx in text if idx.lower().startswith(char.lower())]
      # find all words that start with char
      print(words)
      # for some reason this only prints the letter a bunch of times
      input(&quot;just pausing for no reason&quot;)
      word = random.choice(words) 
      clear()
      print(&quot;The Computers Word: &quot; + word)
      return word
  
  </code></pre>
  <p>The part that I am having trouble with is in finding all of the words from the website that start with a certain letter. for some reason, it is incapable of reading the words as anything but single letters. If possible can you explain to me why it is reading the words as single letters as well as what to do to stop it! I am trying to avoid using BeautifulSoup and other things like that so that I can teach myself python, but I cannot figure this out to save my life.</p>