title: how can I fix this error in this code? index out of range
body: <p>I have a function that let me put any string and return me the high value alphabetically. For instance, if I have a sentence like "Hello world" and we supposed that <code>world</code> is bigger than <code>hello</code> then we will return <code>world</code>.</p>
  
  <p>This high value is measured by index I set before in <code>string_index_in_char</code>.</p>
  
  <pre><code>def func(string):
      char = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
      split_string = string.split()
      i = 0
      x = ""
  
      # get letters
      string = string.lower()
      for s in string:
          if s in char:
              string_index_in_char = char.index(s) + 1
          else:
              string_index_in_char = 0
          x += str(string_index_in_char)
          split_any_char_not_letters = x.split("0")
      # convert string into interger in list  
      for i in range(0, len(split_any_char_not_letters)): 
          split_any_char_not_letters[i] = int(split_any_char_not_letters[i])      
      convert_to_int = split_any_char_not_letters 
  
      # (split_string, convert_to_int) comparison
      n = convert_to_int.index(max(convert_to_int))
      my_string = split_string[n]
      print("%s -&gt; %s" %(string, my_string.lower()))
  
  
  #func("This Is my home")
  func("Hello wOrld")
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "D:\courses\udacity-python\python\Exam\alphabet\alphabet 5.py", line 27, in &lt;module&gt;
      func("This Is my home")
    File "D:\courses\udacity-python\python\Exam\alphabet\alphabet 5.py", line 23, in func
      my_string = split_string[n]
  IndexError: list index out of range
  </code></pre>
  
  <p>No problem appears with me just when I type any other words like <code>"man i need a taxi up to Ubud"</code> or some words. So why it get this error despite it not sending me this error when I type "hello world"?</p>