我有一点清单。问题是我需要根据我拥有的新位来更新该位的值。这是我的代码示例:count=1cycle=3bit_list = ['1','0','1','0']new_bit=['1','0','1']no=''.join(bit_list)bit=''.join(new_bit)while (count<=cycle): for b in no: print (b) print ("end of cycle", count) def bin_add(*args): return bin(sum(int(x, 2) for x in args))[2:] update=bin_add(no,bit) count=count+1print ("updated list",update)我需要以下输出:1010updated list 1011 #1010 + 1end of cycle 11011updated list 1011 #1011 + 0end of cycle 21011updated list 1100 #1011 + 1end of cycle 3请帮我解决这个问题。谢谢你。
添加回答
举报
0/150
提交
取消