Question
Im getting a error for value not defined , I cant figure out whats wrong with the code . This is for Python print() number=input(enter
Im getting a error for value not defined , I cant figure out whats wrong with the code . This is for Python
print()
number=input("enter a number=")
#sum of digits class
class sumofDigit(): def calculate(self,number):
#covert to a string
value=str(number)
sum = 0
# calc sum of three digit number
for each in value: sum=sum+int(each)
print()
print("sum three num into two number=",sum)
print()
# calc sum of two digit num
final= str(sum)
finalsum = 0
# loop
for each in final: finalsum = finalsum+int(each) print()
print("sum of two num into one num =",finalsum)
# create object and method
obj = sumofDigit()
obj.calculate(number)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started