Reputation: 3
Sorry for my bad english
1) I've found the code to sum digits of a number. I use it in a python algorithm and it works fine !
2)I also found how to obtain a base 9 result
def sum(n):
sum_ = n % 9
return sum_ if sum_ != 0 else 9
3) But I don't know how to make exceptions : for instance keeping certain numbers (11 or 22 or the number 10, yes I know, it is not a master number) from the first operation (without reducting/digiting them). It must be very simple but I'm an absolute beginner!
Thanks for your answers
Can someone can help me?
Upvotes: 0
Views: 82
Reputation:
Could you try an be a bit clearer when typing out the question, and fix any typos?
Use if
statements for exceptions.
if n == 10 or n == 11 or n == 22:
return n
I'm not sure if that's exactly what you're asking for but it sounds like it could be the basics you'd find on beginner tutorials.
Upvotes: 1