[Tutor] python coding problem

Ramanathan Muthaiah rus.cahimb at gmail.com
Mon Sep 26 13:52:50 EDT 2016


>
> This is my first time using this so I hope it works.
> I am trying to find out why this code doesnt work.
> Its simple.  I want to find out which number is bigger.
>

Welcome!


>
> I hope you can help and that I am using this python feature properly.
> Thanks.
> The function prints the first two print statements then nothing else
> happens.
>

Have you tried swapping the print and return statement in the
if-elif-elif-else loop ?

>
> def maximum(n1, n2):
>   print "the first number is" ,n1
>   print "the second number is", n2
>   if n1 > n2:
>     return
>     print n1 , "is the bigger number"
>   elif n1 < n2:
>     return n2
>     print n2
>   elif n1 == n2:
>     print "they are equal"
>   else:
>     print "Sorry, No response found"
> maximum(1,2)
>


More information about the Tutor mailing list