title: Detecting the last Iteration in a loop
body: <p>I have a word and I want to split each character from a word.  I use FOR IN loop to split the characters. During split I want to detect first and last characters.  I use a variable count and count is initialized to 0. If count=1 then it is first character.  But similarly how can I detect the last character in FOR IN loop in python</p>
  
  <pre><code>    count=0;
      for w in word:
          count++
          if count==1:
              #first character
  </code></pre>