求解,这道python题怎么解
编写一个Python函数,实现如下功能。
示例1:用户输入t = (1,2,0,0),k = 34 ,输出(1, 2, 3,4)
示例2:用户输入t =(2,7,4),k = 181 ,输出(4,5,5)
示例3:用户输入t =(2,1,5),k = 806 ,输出(1,0,2,1) def func(t, k):
return tuple(map(int, (str(int(''.join(str(each) for each in t)) + k))))
print(func((1,2,0,0), 34)) qiuyouzhi 发表于 2020-11-25 18:55
感谢,感谢 t = input('请输入一个元组:')
k = input('请输入一个数字:')
tuple1 = ()
total = 0
each_num = 0
num = 0
list1 = []
for each_num in t[:]:
if each_num.isdigit():
total = (total+int(each_num))*10
total = total//10
total += int(k)
for each_num in str(total):
list1.append(int(each_num))
tuple1 = tuple(list1)
print(tuple1)
小白的复杂操作{:5_103:} 赐福考官 发表于 2020-11-25 19:07
t = input('请输入一个元组:')
k = input('请输入一个数字:')
tuple1 = ()
感谢,有心了 看到二楼的回复,再看看自己的答案{:10_245:}{:10_245:}{:10_266:}
页:
[1]