0

How to convert nested string list to integer list in or convert nested list to flat list to get max sum in python

I am practicing online geeksforgeeks there is question first line contain input of T testcases 2nd line length of columns 3line contains elements input such as 3 5 6 1 2 3 4 5 6 9 6 3 6 5 https://code.sololearn.com/cxXKQHXLH9dA/?ref=app

3rd Mar 2020, 1:06 PM
Shelly Kapoor
Shelly Kapoor - avatar
9 Answers
+ 5
What you can do to avoid nested lists, is using extend(...) instead of using append(). But you will still have no integers to get the sum. To do this, you can map the int() function to each element coming from the split() function. This could look like this: ... #list1.append(input().split()) list1.extend(list(map(int,input().split()))) print(list1) print(sum(list1))
3rd Mar 2020, 4:53 PM
Lothar
Lothar - avatar
+ 2
Hmm - the code is confusing me, as i don't know what your various inputs mean. May be you can give us a brief desription about this task, or the link to geeksforgeeks? [edited!]: if i input the numbers as you mentioned above, i get this result: 3 5 6 1 2 3 4 5 [['1', '2', '3', '4', '5']] 6 9 6 3 6 5 [['1', '2', '3', '4', '5'], ['6', '9', '6', '3', '6', '5']]
3rd Mar 2020, 4:32 PM
Lothar
Lothar - avatar
+ 1
swim thnx now I am taking multiple inputs at once but I am unable to compute sum of integers in each list now how to convert into flat list?
3rd Mar 2020, 4:18 PM
Shelly Kapoor
Shelly Kapoor - avatar
3rd Mar 2020, 6:31 PM
Shelly Kapoor
Shelly Kapoor - avatar
+ 1
swim ya I know I am taking input many many times I have posted link to problem
3rd Mar 2020, 6:34 PM
Shelly Kapoor
Shelly Kapoor - avatar
0
Lothar can you solve this problem using python
4th Mar 2020, 5:44 AM
Shelly Kapoor
Shelly Kapoor - avatar