def purify(ls): for item in ls : if item % 2.0 != 0.0 : return ls.remove(item) return ls print purify([1,2,3])
@adn77790: Yeah, forget about my last post (that's why we edit it), what's the issue with it?
Thanks for your reply ; well I think that's all, I have problems in return keyword
@adn77790: Oh, glad it was just the return statement.
Edited my last post without a purpose, oh boy.
But just a really quick reminder; pay close attention to the return statments since it will force your code to go back to where the function was called.
In your code, the first return, won't return anything.
lol it's fine thanks by the way
What, if any error messages are you being given?
Can you explain your reasoning for choosing to use a float as the modulus? Doesn't parity imply that a number is evenly divided by the integer,
2? And wouldn't the modulo be
0. I don't see where a float fits into this evaluation.
Removing items from a list we are iterating can have negative consequences that need to be carefully thought out and mitigated.
It's okay i got it you are right
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.