Exception inside a while loop error
<p>I'm trying to get this code to loop until the user gives correct input but after the first loop if the user gives bad input again the program will crash and give me a ValueError</p>

<pre><code>while True:
    try:
        input1,input2= input("Enter the Lat and Long of the source point separated by a comma eg 50,30").split(',')
        break
    except ValueError:
        print ("please Use a Comma")
        input1,input2 = input("Enter the Lat and Long of the source point separated by a comma eg 50,30").split(',')
</code></pre>

<p>The trick would be in using the <em>continue</em> statement when you get the exception. That will restart the loop and go into the area protected by the <em>try</em> statement so if you get another exception it won't crash your program.</p>

<pre><code>while True:
    try:
        value1, value2 = input("Enter the Lat and Long of the source point separated by a comma eg 50,30: ").split(',') 
        break
    except ValueError:
        print("Please Use a Comma")
        continue
</code></pre>

python while-loop exception-handling