[Solved] write a program that determines if user input is even or odd and loops


If you want to check whether the input is zero before doing anything else, do so. If you want to stop the loop in certain conditions, put the break inside a conditional. Note that count and total were unused. Also, format() with no formatting is redundant.

def main():

    while True:
        entry = int(input('Enter a number or 0 to quit:'))    
        if entry == 0:
            print('All done!')
            break
        if entry % 2 == 0:
            print(entry, 'is an even number.')
        else:
            print(entry, 'is an odd number.')

main()

2

solved write a program that determines if user input is even or odd and loops