python - Convert certain values in list to int -
i have list of lists , want convert second value in each list int since string
[['hello','how','are','you','1'],['hello','how','are','you','2']]
i trying convert index 4 int in each list within larger list when do
for hi in above: int(hi[4])
it returning int when print list , not entire list.
just traverse , convert using int()
function every 4th element in every list inside :
for li in my_list: li[4] = int(li[4])
Comments
Post a Comment