Last modified: Jan 10, 2023 By Alexander Williams
how to convert python list str to int
in this tutorial we'll learn how to convert a string list to int list
syntax
1 | list(map(int, your_list) |
example
1 2 3 4 5 6 7 8 | #list str_list = ['1', '2', '3', '4', '5', '6'] #convert list str to int conv = list(map(int, str_list)) #print print(conv) |
output
[1, 2, 3, 4, 5, 6]