为了账号安全,请及时绑定邮箱和手机立即绑定

使用python中的while循环更新位列表

使用python中的while循环更新位列表

12345678_0001 2021-05-13 14:14:02
我有一点清单。问题是我需要根据我拥有的新位来更新该位的值。这是我的代码示例: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请帮我解决这个问题。谢谢你。
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 154 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号