Exercize to understand from three numbers which is more high

Frank Millman frank at chagford.com
Mon Jan 28 04:57:01 EST 2019


"^Bart"  wrote in message news:q2mghh$ah6$1 at gioia.aioe.org...
>
> > 1. The last two lines appear to be indented under the 'if number3 < ' 
> > line. I think you want them to be unindented so that they run every 
> > time.
>
> I'm sorry but I didn't completely understand what you wrote about the last 
> two lines, please could you write how my code could be fixed?
>

The last four lines of your program look like this -

if number3 < number2 and number3 < number1:
     numbermin = number3

     print("Number min is: ",numbermin)

     numbermiddle = (number1+number2+number3)-(numbermax+numbermin)

     print("Number middle is: ",numbermiddle)

The last three lines all fall under the 'if number3 < number2' line, so they 
will only be executed if that line evaluates to True.

I think that you want the last two lines to be executed every time. If so, 
they should be lined up underneath the 'if', not the 'print'.

>
> >     if a == 1:
> >         do something
> >     elif a == 2:
> >         do something else
>
> Finally I understood the differences between if and elif! Lol! :D
>

It is actually short for 'else if', but I guess it is not obvious if you 
have not seen it before!

Frank





More information about the Python-list mailing list