-1

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))
Austin
  • 25,759
  • 4
  • 25
  • 48
LOWERCASE
  • 25
  • 1
  • 4

1 Answers1

2

You can do map directly on split:

l = list(map(int, input().strip().split()))
Austin
  • 25,759
  • 4
  • 25
  • 48