how to convert strings to integers in a list?

Back to General discussions forum

iTz Jner     2022-05-17 22:56:32
User avatar

in the last exercises I have done I have tried to find the most optimal way to pass a list of strings to a list of integers, the best I have been able to do is the following: entry = [int (x) for x in input().split()] How else could you use this conversion?

Moff     2022-05-18 05:51:02
User avatar

List comprehension [int (x) for x in input().split()] is good way for Python. Another approach is using map function: list(map(int, s.split()))

Please login and solve 5 problems to be able to post at forum