title: Index error in Python: "string index out of range"
body: <p>I'm a beginner programmer and as practice I want to make a code that would print every word in a sentence into a new line given that the word starts with h-z.</p>
  
  <p>Here's the code I made:</p>
  
  <pre class="lang-py prettyprint-override"><code>random_phrase = "Wheresoever you go, go with all your heart"
  word = ""
  for ltr in random_phrase:
      if ltr.isalpha():
          word += ltr
      else:
          if word.lower()[0] &gt; "g":
              print(word)
              word = ""
          else:
              word = ""
  </code></pre>
  
  <p>After it prints you, there's a line of empty space, then the index error occurs. What did I do wrong?</p>