Exercize to understand from three numbers which is more high

Ian Clark ianhclark510 at gmail.com
Tue Jan 29 19:30:56 EST 2019


Like this?

num_max = 0
num_index = 0
name_list =
['first','second','third','fourth','fifth','sixth','seventh','eighth','ninth','tenth']
name_it = name_list.pop(0)


while num_index <3:
 try:
  num_list = int( input(f"Insert the {name_it} number: "))

 except ValueError:
  print('Not a number, try again!')
 else:
  num_index += 1
  if num_list > num_max:
   num_max = num_list
  name_it = name_list.pop(0)

print(f"Max number is: {num_max}")

On Tue, Jan 29, 2019 at 1:26 PM Chris Angelico <rosuav at gmail.com> wrote:

> On Wed, Jan 30, 2019 at 8:20 AM Bob van der Poel <bob at mellowood.ca> wrote:
> > Isn't the easiest way to do this is:
> >
> >      sorted( [n1,n2,n3] )[-1]
> >
> > to get the largest value?
>
> >>> help(max)
>
> But the point of this exercise is not to use sorted() or max().
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list