Q:

Trouble with a while loop and user input in python

I have a script that converts Degrees Minutes Seconds to Decimal Degrees and I'm having trouble with this while loop:
lat_dir = raw_input("For your latitude coordinates, please enter N for northern hemisphere or S for southern hemisphere: ")

while lat_dir <> "N" or lat_dir <> "S": #check input to confirm lat_dir = N or S
    lat_dir = raw_input("Please enter N for northern hemisphere or S for Southern hemisphere: ")

I also use a very similar while loop for east and west, and it gives me the same problem. I want it to loop until the proper Input is given, but if I use a while loop like this, it won't break out of the loop no matter what. I also tried an if loop, and it works as long as you give an "N" or "S", otherwise it will error later on in the script. Otherwise my code runs perfectly. 

A:

You should use and instead of or in your check.
 while lat_dir <> "N" and lat_dir <> "S":

