So I am trying to write a code to find out the if a number is divisible by 3. The steps go like this, enter number, add all digits, if digits greater than 10 add digits together until below 10, see if the digit remaining is 3, 6 or 9 and then print out if it is divisible by 3 or not. Here is my code so far:
user_input = int(input('Enter number: '))
sum = 0
for num in user_input:
sum += int(num)
if sum > 10:
while sum > 10:
sum = 0
for num in user_input:
sum += int(num)
if sum == 3 or 6 or 9:
print('Your number is divisble by 3')
else:
print('Your number is not divisible by 3')
else:
if sum == 3 or 6 or 9:
print('Your number is divisble by 3')
else:
print('Your number is not divisible by 3')
Anyone know how to fix the bug?