Your if condition is wrong. Just having b less than 10 is not enough. Can you think about what should it be changed to?
if
b