0

Suppose i have a string a='SKDKFJKFLKG' and I want to store it in a matrix with each letter as an element of the matrix.I am using the following code to store it in a matrix:

def chunks(l, n):

    for i in range(0, len(l), n):
        yield l[i:i+n]
pprint.pprint(list(chunks(a, 1)))

Output:

['S', 'K', 'D', 'K', 'F', 'J', 'K', 'F', 'L', 'K', 'G']

What should i do if i want only 4 characters in each row of the matrix?

Dinesh91
  • 21
  • 3

0 Answers0