Skip to content

Several values on one line

Read · 1 of 4

split, then map

input().split() cuts a line at the spaces: "3 4" becomes ["3", "4"].

map(int, …) turns every piece into a number. So a, b = map(int, input().split()) reads two numbers from one line. You'll write this line in almost every DSA problem.