Reputation: 1
For some reason, the outputs to the calculation multiply = func1_input * 9
gives a repeating number from input e.g. 5555555
if 5
is entered.
Also for the calculation for sum of digits
the output is what you would expect multiply
to give.
def function1():
while True:
try:
func1_input = input("Please enter a number between 1 and 9: ")
val = int(func1_input)
if 1 <= val <= 9:
print("You selected: ",func1_input)
print("\n")
function2(func1_input)
break
else:
print("Invalid input. Please enter again.")
function1()
except ValueError:
print("number not entered")
def function2(func1_input):
func2_input = int(input("What is 10-1?: "))
if func2_input == 9:
print("Your number is: ",func2_input)
print("\n")
multiply = func1_input*9
print("Your number multiplied by 9 is: ",multiply)
function3(multiply)
else:
print("Invalid input. Please enter again.")
function2(func2_input)
def function3(multiply):
sum_of_digits = sum(int(digit) for digit in str(multiply))
print("Adding up the individual digits of your number gives: ",sum_of_digits)
function4(sum_of_digits)
Upvotes: 1
Views: 40
Reputation: 121
Your error is in the line function2(func1_input)
. It should be function2(val)
.
Upvotes: 1