When it outputs the answer for this, it puts them in parentheses. Can someone help me remove them?
Code:
n=int(input())
def rev(steps,n):
sum = n + int(str(n)[::-1])
if str(sum) == str(sum)[::-1]:
return (steps,sum)
else:
return rev(steps+1,sum)
print(rev(1,n))
If I input 87, it would output something like (4,4884), which is correct, but I just need to remove the parentheses
n=int(input())
def rev(steps,n):
sum = n + int(str(n)[::-1])
if str(sum) == str(sum)[::-1]:
return (steps,sum)
else:
return rev(steps+1,sum)
print(*rev(1,n), sep=', ')
Will print 4, 4884
with input 87
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.