jeremslol
jeremslol

Reputation: 13

Converting Multiple string inputs to int

I'm trying to convert a, b, c, d to integers, but after I've tried doing this they still come up as strings. I've tried using a loop instead of map, but that didn't work either.

inputs = input()
split_input = inputs.split()
a, b, c, d = split_input
split_input = list(map(int, split_input))

Upvotes: 0

Views: 541

Answers (1)

user2390182
user2390182

Reputation: 73450

Just swap the last 2 lines:

split_input = list(map(int, split_input))
a, b, c, d = split_input

Unless you need split_input later on, you don't need the list conversion at all:

split_input = map(int, split_input)
a, b, c, d = split_input
# OR in fact simply
a, b, c, d = map(int, split_input)

Upvotes: 2

Related Questions