title: Check if the character is the VERY LAST one in my string?
body: <p>sorry if this is a duplicate, but I haven't found any clear answer out there.</p>
  
  <p>Basically, my program should capitalize a string like this :</p>
  
  <pre><code>'some words'
  </code></pre>
  
  <p>Into something like this :</p>
  
  <pre><code>'Some Words'
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>mystring = "some words"
  copy_of_mystring = ""
  word = ""
  
  for i in mystring:
      if i==" ":
          for j in range(1):
  
              #capitalize if my word has more than 1 letter
              if len(word) &gt; 1:
                  word=str.upper(word[0]) + word[1:]
  
              #capitalize if word has only 1 letter
              elif len(word)==1:
                  word=str.upper(word[0])
  
              copy_of_mystring += word + " "
          word = ""
      else:
          word += i
  print(copy_of_mystring)
  </code></pre>
  
  <p>So basically my first loop add <code>i</code> to <code>word</code> until <code>i</code> is a space.</p>
  
  <p>Then my second loop will start and capitalize <code>word</code> and add it to <code>copy_of_mystring</code>, that part is working.</p>
  
  <p>And this is when my problem comes in. When my first loop is "building" my last word, it will of course won't find any space after it, so my problem comes from this condition :</p>
  
  <pre><code>if i==" ":
  </code></pre>
  
  <p>I tried this :</p>
  
  <pre><code>if i==" " or i==mystring[-1]:
  </code></pre>
  
  <p>But, in a string where several characters is the same as the last one, like in <code>'morgana'</code>, for example, it would end up like this</p>
  
  <pre><code>'Morg N'
  </code></pre>
  
  <p>So, is there a way to check if my character <code>i</code> is the VERY LAST one in <code>mystring</code> ?</p>
  
  <p>P.S: Sorry if this sounds like a really basic mistake but I'm still learning all the things we can do with strings.</p>