filmov
tv
2 ways to convert Python list of strings to integers 🐍 #shorts

Показать описание
1. list comprehension: [ int(x) for x in list1]
2. functional: list(map(int, list1))
I think list comprehension is easier to read, but will use functional for a list of lists to keep from nesting list comprehensions.
2. functional: list(map(int, list1))
I think list comprehension is easier to read, but will use functional for a list of lists to keep from nesting list comprehensions.