title: How to make my code detect end of string in python?
body: <p>I'm trying to write code to split a sentence without it's punctuation. For example, if a user inputs <code>"Hello, how are you?"</code>, I can split the sentence to <code>['hello','how','are','you']</code></p>
  
  <pre><code>userinput = str(raw_input("Enter your sentence: "))
  
  def sentence_split(sentence):
      result = []
      current_word = ""
      for letter in sentence:
          if letter.isalnum(): 
              current_word += letter     
          else: ## this is a symbol or punctuation, e.g. reach end of a word
              if current_word: 
                  result.append(current_word)
                  current_word = "" ## reinitialise for creating a new word
      return result
  
  print "Split of your sentence:", sentence_split(userinput)
  </code></pre>
  
  <p>so far my code works, but if i put a sentence without ending it with a punctuation, the last word won't show up in result, for example, if the input were <code>"Hello, how are you"</code>, the result would be <code>['hello','how','are']</code>, I guess it's because there's no punctuation to tell the code the string is ended, is there a way I can make the program detect it's the end of string? So that even if the input were <code>"Hello, how are you"</code>, the result would still be <code>['hello','how','are','you']</code>.</p>