I'm trying to take a single line of intergers and using a for loop to convert the elements into integers, Is there a more pyhtonic way of doing so??
a = input().strip().split()
l = []
for i in a:
l.append(int(i))
I'm trying to take a single line of intergers and using a for loop to convert the elements into integers, Is there a more pyhtonic way of doing so??
a = input().strip().split()
l = []
for i in a:
l.append(int(i))
You can do map
directly on split
:
l = list(map(int, input().strip().split()))