[Solved] How to read input in python using raw_input [closed]


raw_input() takes in a line of input as a string. The .split() string method produces a list of the whitespace-separated words in a string. int() parses a string as an int. So putting that together, you can read the input you want using

t = int(raw_input())
cases = []
for i in range(t):
    cases.append( map(int, raw_input().split()) )

This will give you a list of a,b pairs if the input is in the correct format, but won’t do any error checking.

solved How to read input in python using raw_input [closed]