def sum_of_squares_of_digits(a):
a = input("Enter the rpm ")
s = sum(int(c) ** 2 for c in str(a))
print s
m = s * 323
print m
r = a%10
e = a/10
x = e%10
u = int(str(r) + str(e))
f = u%10
h = u/10
l = h%10
t = int(str(l) + str(f))
result = m+t
print u
print t
print result
sum_of_squares_of_digits(2)
在上面的代码中,我需要取" result"的值。并将其作为" a"的输入。并执行10次。
答案 0 :(得分:0)
您应首先return
来自您的函数的变量result
:
def sum_of_squares_of_digits(a):
...
return result
然后你可以调用该函数并使用for
loop执行10次:
res = sum_of_squares_of_digits(2) # first call with 2 like in your program
for i in range(10):
res = sum_of_squares_of_digits(res) # next 10 calls with the returned value