Is there a need for range(len(a))?

后端 未结 11 725
执念已碎
执念已碎 2020-12-02 05:05

One frequently finds expressions of this type in python questions on SO. Either for just accessing all items of the iterable

for i in range(len(a)):
    prin         


        
11条回答
  •  醉酒成梦
    2020-12-02 05:44

    My code is:

    s=["9"]*int(input())
    for I in range(len(s)):
        while not set(s[I])<=set('01'):s[i]=input(i)
    print(bin(sum([int(x,2)for x in s]))[2:])
    

    It is a binary adder but I don't think the range len or the inside can be replaced to make it smaller/better.

提交回复
热议问题