Python Forum

Full Version: Loop question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Extremely new to programming, and I am trying to get this whole loop thing down. I am doing one of the assignment's that I am sure you all have probably seen a hundred times; I am doing the gross pay and over time pay calculator. I have everything done with the exception of getting the program to loop with the user ability to stop it.

With the example below I got the program to loop for me but now it seems like it just skips the if statement and moves right into the else statement.

Example:
while a ==0:
   n = input("Enter employee's name or press 0 to quit:")
   print()
   if n==0:
        exit
Again, very new to this so any and all help is much appreciated.
input returns a string (in python3) so what you'd want is:
if n == "0":
   break
or similar.
Thank you! is it the break that made a difference or was it "0" that made the difference?
It's '0'. As @Mekire said, input() returns a string so you compare 'n' which is string against an integer.