I'm a freshie. I would like to convert a numeric string into int from a sublist in Python. But not getting accurate results. 😔
countitem = 0
list_samp = [['1','2','blue'],['1','66','green'],['1','88','purple']]
for list in list_samp:
countitem =+1
for element in list:
convert_element = int(list_samp[countitem][0])
list_samp[countitem][1] = convert_element
[[int(i) if i.isdecimal() else i for i in l] for l in list_samp]elementanywhere inside it. Do you want to convert the first element to int or all elements that can be converted?