Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Python/TestFor9.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ def test_for_9(quotient):
a multiple of 9, without using the modulo operator.
This can be done, by checking if the digit sum,
is 9, once it gets to be a single digit."""
digit_sum = int(quotient)
while digit_sum > 9:
digits = str(digit_sum)
digit_sum = int(quotient) # Takes the given number and convert into int
while digit_sum > 9: # Checks if the number provided by user is greater than 9
digits = str(digit_sum) # Convert digits into string for individual purpose
total = 0
for digit in digits:
total += int(digit)
for digit in digits: # For loop to use individual digit for digit sum
total += int(digit) # Adds each digit to get digit sum
digit_sum = total
if digit_sum == 9:
if digit_sum == 9: # If loop for digit sum == 9
return True
else:
return False
Expand Down