title: What is wrong with my if statement? Python
body: <p>I cannot seem to figure out why my if statement is not working. I'm new to programming and I am trying to create a hangman game to test how I'm doing. I have it set up so that the code will select a random word, count the letters of that word, place dashes to show where each letter will be. At this point I'm trying to use an if statement that is going to index each letter, until it is finished with all of the letters. Here is the code.</p>
  
  <pre><code>"""
  python simple.py
  """
  
  from random_words import RandomWords
  rw = RandomWords()
  word = rw.random_word()
  print(word)
  
  word_len = len(word)
  print(("___" + "   ") * word_len)
  def letters(word):
      if word_len &gt;= 0:
          letter1 = word[0]
      else:
          pass
      if word_len &gt;= 1:
          letter2 = word[1]
      else:
          pass
      if word_len &gt;= 2:
          letter3 = word[2]
      else:
          pass
      if word_len &gt;= 3:
          letter4 = word[3]
      else:
          pass
      if word_len &gt;= 4:
          letter5 = word[4]
      else:
          pass
      if word_len &gt;= 5:
          letter6 = word[5]
      else:
          pass
      if word_len &gt;= 6:
          letter7 = word[6]
      else:
          pass
      if word_len &gt;= 7:
          letter8 = word[7]
      else:
  
  print(letters(word))
  </code></pre>
  
  <p>The error I get is as follows:</p>
  
  <pre><code>Traceback (most recent call last):
    File "simple.py", line 46, in &lt;module&gt;
      print(letters(word))
    File "simple.py", line 30, in letters
      letter5 = word[4]
  IndexError: string index out of range
  </code></pre>