Skip to content
Advertisement

Return True if any number is even inside a list else return false

I am new to Python. I am doing some exercise online.

JavaScript

if I key run the code below

JavaScript

It will return True. But I have one question, is the for loop only check until 8 then the for loop will break? or it actually runs and checks until 21 even though the 8 is an even number that already meets the requirement?

Advertisement

Answer

At the time when your program was executing the statement return True in your code, input_number was 8 and for loop had more iterations left. But return statement causes this flow to break and immediately return to the code which called the function – which is outside of the function.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement