Given a Number to find sum of Digit in Python
Example:-
input = 356
Output = 14
Below the method to Sum of Digit Only Allow for Three digit
three_digit = input(“Type a Three Digit Number: “)
first_digit = three_digit[0]
second_digit = three_digit[1]
third_digit = three_digit[2]
result = int(first_digit) + int(second_digit) + int(third_digit) print(result)
OUTPUT:-

Method – 2 Using for loop function for infinite Digit :
test = input(“Type How Many Digit for sum: “)
sum = 0 for i in test:
sum += int(i)
print(sum)
OUTPUT:-

Thank You ! ❤️