-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,142
  • 4
  • 21
  • 46
LOWERCASE
  • 25
  • 3

1 Answers1

2

You can do map directly on split:

l = list(map(int, input().strip().split()))
Austin
  • 25,142
  • 4
  • 21
  • 46