+ 1

Many lines to one variable/list

Lets say i copy paste many lines and i want to put it in a list or other stracture,how i do that without indexing each line manualy? Example:138373782 1334493 13444 443392827 3338383773930 39383737 .... ...

30th Oct 2018, 11:01 AM
gil gil
2 Respostas
+ 6
Solution 1: my_list = [138373782, 1334493, 13444, 443392827, 3338383773930, 39383737] This is what I usually do, but here you'd have to add the commas manually :( Solution 2: my_list = """138373782 1334493 13444 443392827 3338383773930 39383737""".split() Here we won't need those commas, but the numbers are treated as strings, which you may not have wanted. Solution 3 my_list = [int(i) for i in """138373782 1334493 13444 443392827 3338383773930 39383737""".split()] This fixes the issue with solution 2, but string-int conversion takes time.
30th Oct 2018, 11:20 AM
Kishalaya Saha
Kishalaya Saha - avatar
+ 1
Kishalaya Saha thanks man
30th Oct 2018, 11:24 AM
gil gil