Interestingly the above code failed for some reason earlier and that's why I checked for `None1` using a loop. Now the `None in solution` works. I guess the failure earlier must have been due to some other issue.