I did a bit of digging and it appears that using if in a lambda function requires us to use else as well since the function needs to know what to return in the case when if is false. Please see this reference. With that said, I believe the solution to your problem would look like this:
survey_roles_yes_WandM[‘MonthsProgramming’] =
survey_roles_yes_WandM[‘MonthsProgramming’].apply(lambda x: x+1 if x == 0 else x)