title: How do I find the last position of a comma in a string?
body: <p>I'm a newbie and trying to find the last position of a comma in a string. I'd like to use a while loop as shown below in my code. I get really frustrated when I code sometimes because I seem to struggle with easy logic. Anyways, here is my code:</p>
  
  <pre><code># Find last occurrence of the comma
      while True:
          commaPos = newNameStr.find(",", 0)
          if commaPos == -1:
              return the commaPos before
  </code></pre>
  
  <p>Am I on the right track? I took a Python course from Udacity and we had a similar problem and they solved it like this but I forgot how they wrote the code.</p>