0

I'm trying to write a function that returns the first even number in a list, using a while loop

def first_even(list):
    while i%2 !=0:   #I'm not sure if this is a good start for the while loop, but I think I'm supposed to use something%2...
        #no idea what to do here

1 Answers1

1

A good and very short coding style will be:

  for i in list:
     if i%2 == 0:
        return i
Jay Kumar R
  • 537
  • 2
  • 7