0

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))
1
  • 1
    Your a, b, c and d variables are assigned the result of splatting the split_input array, which is an array of strings at the moment when this assignment is happening. Move your map operation to happen first, so that you assign from the result of that instead Commented Nov 3, 2021 at 14:08

1 Answer 1

2

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.