0

i'm trying to flip the bits of a 32-bit binary number but somehow its not working properly. it doesnt even ask for an input. i dont know whats going on.

    def flip_bits(k):
    for j in range(len(k)):
        if k[i] == 1:
            k[i] = 0
        elif k[i] == 0:
            k[i] = 1
    print(k)

if __name__ == '__init__':
    t = int(input())
    a = []
    b = []
    for i in range(t):
        a.append(int(input()))
        b.append(bin(a[i])[2:].zfill(32))
    flip_bits(b)

if i remove the if name = 'init' part it takes the input but doesn't give me an appropriate output can u please direct me in the right path?

shyam padia
  • 397
  • 4
  • 16

1 Answers1

1

It should be __main__ not __init__

if __name__ == '__main__':

what-does-if-name-main-do

Community
  • 1
  • 1
Padraic Cunningham
  • 176,452
  • 29
  • 245
  • 321