0

Hello,

pls can anybody help me to break following string?

example:

output is 000 (type str) an I need to get [0,0,0]

here is a script:

def test(n_input):
    bin_n=2
    r=bin_n**n_input
##    print r

    for x in range(r):
##        print bin(x)
        f=str(bin(x))[2:].zfill(n_input) # x is type int, f is type str
        print type(f)

result is:
000
001
010
011
100
101
110
111

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by pyTony
0

With list as I posted earlier:

def test(n_input):
    for x in range(2**n_input):
        f=str(bin(x))[2:].zfill(n_input) # x is type int, f is type str
        print list(f)

test(3)

Edited by pyTony: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.