Answers for "how to make whole list into integer python"

18

change list to int in python

test_list = list(map(int,test_list))
Posted by: Guest on April-27-2020
1

python convert list of lists of strings to int

# Example usage using list comprehension:
# Say you have the following list of lists of strings and want integers
x = [['565.0', '575.0'], ['1215.0', '245.0'], ['1740.0', '245.0']]
list_of_integers = [[int(float(j)) for j in i] for i in x]

print(list_of_integers)
--> [[565, 575], [1215, 245], [1740, 245]]

# Note, if the strings don't have decimals, you can omit float()
Posted by: Guest on November-06-2020

Code answers related to "how to make whole list into integer python"

Python Answers by Framework

Browse Popular Code Answers by Language