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
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
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
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
--
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