I want to convert the strings in sublists into integer. Here is the code,
Example Input:
totalclient=[['5', '110'], ['9', '500'], ['20', '400']]
totalhouse=[['10', '100'], ['2', '200'], ['30', '300']]
This example list has only 4 sublists, But I want to process over 700 sublists for two lists and every sublist will have more than 300 strings!
Code:
totalclient = [list(map(int, sublist)) for sublist in totalclient]
totalhouse = [list(map(int, sublist)) for sublist in totalhouse]
Output
[[5, 110], [9, 500], [20, 400]]
[[10, 100], [2, 200], [30, 300]]
Above code works for me! But for loop takes too much time to convert it is there any other way to convert it into integer without using for loop?
I tried to convert sublist while inputting sublists like belowcode but it also takes same time!
for i in range(0,n[0]):
client=[int(x) for x in input().split()]
totalclient.append(client)