I have nested lists.in this lists, every nested list contains two component and each component may contain blank (' ') character.I wanted to delete and wrote a piece of code but couldn't make it work.How can i overcome this problem ?
the nested List of List is :
[['bike', '2 * wheel+1* frame'], ['wheel', '1 * rim + 1* spoke +1 *hub'], ['rim', 60], ['spoke', 120], ['hub', '2*gear+1*axle'], ['gear', 25], ['axle', '5*bolt+7*nut'],['bolt',0.1], ['nut', 0.15],['frame', '1*rearframe+ 1*frontframe'],['rearframe', 175],['frontframe', '1*fork+2*handle'], ['fork', 22.5],['handle', 10.0]]
As seen there are some blanks in some strings.
The python code i wrote :
def blanks(des):
a = 0
while a < len(des):
if type(des[0][1]) == str:
des[0][0] = des[0][0].replace(' ','')
if type(des[0][1]) == str:
des[0][1] = des[0][1].replace(' ','')
a += 1
return des