# Can you transform strings with numeral into a list in pyhton

I'm very knew to programming. During my course in university we have to work with spyder writing python, but mostly using sql. I am struggling a lot with a problem where transfering a list to a DataBase it transforms it into string, and when i wish to use it all comes in string, so for example list[0]=[ . I've scowered the Internet for answers and tried everything but i can't seem to find an answer. Well actually, i haven't tried doing a for cycle, but i think that would make the function even more confusing for me, at least.

And here's the function i've been working on, the line with the r is just me messing with to see if i can find a solution

``````def GRAFICO(nomeBD, codigo):
bd=sql.connect(nomeBD, isolation_level=None)
com='SELECT IdV, Cargas, Deflecao, Comp, ASeccaoA, ASeccaoB, IdMV FROM Ensaios, Vigas WHERE IdV=IdE AND IdMV='+'"'+codigo+'"'+';'
res= bd.execute(com).fetchall()
n=len(list(res[0][1]))
m=len(res)
M=res[0][6]
E_total=[]
Id_total=''
w_total=''
for r in range(m+1):
Id_total=Id_total+res[r][0]
print(Id_total)
w_total=w_total+res[r][1]
print(w_total)
for i in range(n+1):
w=res[r][1][i]
r= [int(word) for word in w.split() if word.isdigit()]
print(r)
delta=res[r][2][i]
L=res[r][3]
a=res[r][4]
b=res[r][5]
E=equacao(w, delta, L, a, b)
E_total.append(E)
Media=media(E_total)
plot1(w_total, E_total, Id_total, Media, M)
``````

The problem is i get a list like this w=['101', '109', '118', '128', '141', '157', '176'], but if i do list(w), i get this: ['[', "'", '1', '0', '1', "'", ',', ' ', "'", '1', '0', '9', "'", ',', ' ', "'", '1', '1', '8', "'", ',', ' ', "'", '1', '2', '8', "'", ',', ' ', "'", '1', '4', '1', "'", ',', ' ', "'", '1', '5', '7', "'", ',', ' ', "'", '1', '7', '6', "'", ']']. It's all in string, I'd like to be able to do w[0] and the output be 101, not '['

If you could help me it would be very much apreciated