Q:

Code outputs right information but the formatting is incorrect, How do you segment a string?

This is my code:
def string2bin(s):
y = []
for x in s:
    q = []
    q.append(str(bin(ord(x))[2:].zfill(8)))
    y.append(q)
return y

It is supposed to output:
string2bin('abc')
[[0, 1, 1, 0, 0, 0, 0, 1], [0, 1, 1, 0, 0, 0, 1, 0],
 [0, 1, 1, 0, 0, 0, 1, 1]]

But instead outputs:
string2bin('abc')
[['01100001'], ['01100010'], ['01100011']]

Also how do you segment a string?
Thanks for any help!

A:

Convert the string to a list of digits.
def string2bin(s):
    y = []
    for x in s:
        q = [int(c) for c in (str(bin(ord(x))[2:].fill(8)))]
        y.append(q)
    return y

