[Tutor] How to print a variable from an if/else statement
Joel Goldstick
joel.goldstick at gmail.com
Wed Sep 12 12:05:38 CEST 2012
On Wed, Sep 12, 2012 at 5:32 AM, <chrisbva81 at gmail.com> wrote:
> Hello,
>
> I'm very new thanks in advance for your help.
>
> My If statement is:
>
> If age < (40):
this will work, but python doesn't need the parentheses around the
second argument. You can use it to make the logic more clear, but for
a single term it doesn't
> Print("you are young.")
> Else:
in python else is lower case
> Print("You look great.")
>
> Basically what I want to do is have a sentence using print that includes the results of the If or Else which is based on the users input of age.
>
> I don't know if I'm doing something wrong by doing it this way. I can't figure it out.
>
so try this:
if age < 40:
print ("you are young")
else:
print ("you look great!")
--
Joel Goldstick
More information about the Tutor
mailing list