0

I am attempting to make my calculator a little better. Want to only accept valid inputs and attempt to make my code more fluid and less clunky. So any feedback in appreciated. I am having trouble with 'press q to quit' and when i type in something like 'r' it still executes the code. I've tried

while True:
    print 'For addition press 1: '

    print 'For subtraction press 2: '

    print 'For multiplication press 3: '

    print 'For division press 4: '
    print ' '

    choice = raw_input('Please enter your operation 1-4: ')

    if choice == '1':
        print ' '
        print "Welcome to Addition!"

        num1 = float(input('Enter first number: '))
        num2 = float(input('Enter second number: '))

        print num1, '+', num2, '=', addition(num1,num2)
        print ' '
        print ' '

        choice = raw_input('Press Enter to continue / q to quit: ')
        if choice == 'q':
            exit()
        if choice != 'q':
            print 'Not Valid Input '
        choice = raw_input('Press q to quit ')
        if choice == 'q':
            exit()   

I get caught in limbo here. I know there is a way to make this work. Any help is greatly appreciated. Thanks.

Kyle Higginson
  • 922
  • 6
  • 11
Placebo
  • 3
  • 3

0 Answers0