Why am I getting a None result at the end of the code output?: numbers = [951, 402, 984, 651, 360, 69, 408, 319, 601, 485, 980, 507, 725, 412, 547, 544, 615, 83] def print_even(numbers): for e in numbers: if e == 412: break elif e % 2 == 0: print e #return e #print print_even(numbers) //don't double print or you'll get a None at the end of your output! Found the problem need to remove print in the call to the function! as in: print_even(numbers)
Your function is already calling "print" to print out each number. When you call print_even(numbers), you call "print" again which is redundant and actually not only runs print_even, but prints out what print_even *returns* as well, which right now is nothing (printing and returning are not the same thing). It's very easy to fix: just remove the word "print" in your last line.
Oh thanks - Didn't see your response!
Join our real-time social learning platform and learn together with your friends!