Avatar ·

Create a list of lines with numbers through a gap

📁 string, Advanced Python Topics, work

There is a string:

'45 30 55 20 80 20 '.

It is necessary to create an array from the numbers included in this string:

[45, 30, 55, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20 80, 20].

I thought for a long time and came only to such a code, but it just does not work:


for i in range(len(q)):
    if q[i] != (' '):
        e += q[i]
    else:
        w.append(e)