On 07/04/2013 00:10, Soliman, Yasmin wrote:

To quote John McEnroe "You cannot be serious". Thankfully Steven D'Aprano has already given you a roadmap to follow. I'll point out a few things that should assist.

How can I fix this loop so that it multiplies the two intergers and if
user types in 'quit' for either number it stops? if not it keeps going.

def multiply_integers(int1,int2):
     print int1*int2

multiply_integers will return None, the Python default.


int1=float(input('Please enter 1st integer: '))
int2=float(input('Please enter 2nd integer: '))

Are you trying to get integers from the input by calling float? Or could that be interest? Or what? The print statement later on tells me you're using Python 2.x. Therefore you should be using raw_input above and *NOT* input, the latter is highly dangerous.



while True:
             multiply_integers= int("int1, int2")

Having defined a function you now try to reassign its name, obviously not what you want. But that won't work as the call to int will fail as you're passing a single string "int1, int2" to it.

             print int1*int2

Why print this here when your function multiply_integers already does exactly that?


             if multiply_integers == 'Quit':

You now try to compare your function to a string. Or should multiply_integers be an int here?

                         print '\nThank you for using this program! Bye.'
                         break
             else:
                         print 'Not quitting'


--
If you're using GoogleCrap™ please read this http://wiki.python.org/moin/GoogleGroupsPython.

Mark Lawrence

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to