Re: while statements

2007-10-16 Thread Zentrader
O> > while cal <=0: > >#Prompt for calories > >cal = input("Please enter the number of calories in your food: ") > >if cal <=0: > >print "Error. The number of calories must be positive." > > >#Prompt for fat > >fat = input("Please enter the number of fat

Re: while statements

2007-10-16 Thread martyw
Shawn Minisall wrote: > I just learned about while statements and get why you place them around > inputs for validation, but I'm a little lost on exactly where to place > it with what condition in this program where the number of fat grams > exceeds the total number of calories so that it loops

Re: while statements

2007-10-16 Thread kyosohma
On Oct 16, 8:28 am, Shawn Minisall <[EMAIL PROTECTED]> wrote: > I just learned about while statements and get why you place them around > inputs for validation, but I'm a little lost on exactly where to place > it with what condition in this program where the number of fat grams > exceeds the total

Re: while statements

2007-10-16 Thread Francesco Guerrieri
On 10/16/07, danfolkes <[EMAIL PROTECTED]> wrote: > Instead of: if(cal<=0) > > you could do : > cal=0 > while cal<=0: > cal = int(raw_input("Please enter the number of calories in your > food: ")) > > that would make sure that your input is > 0 Calories could be non integer :) francesco --

Re: while statements

2007-10-16 Thread danfolkes
On Oct 16, 9:28 am, Shawn Minisall <[EMAIL PROTECTED]> wrote: > I just learned about while statements and get why you place them around > inputs for validation, but I'm a little lost on exactly where to place > it with what condition in this program where the number of fat grams > exceeds the total