how to raw_input in python when many lines are given?

Back to General discussions forum

Backflip     2015-07-03 00:44:37

I am storing that lines just inside of my source code.But I want to make it possible to do it the normal way.

Christopher Matthews     2015-07-03 10:07:25

There are several ways.

You could use:

sys.stdin.readlines()

Or,

n = int(input())
lines = []
for _ in range(n):
    lines.append(input())

Personally, I would use something like:

n = int(input())
lines = [input() for _ in range(n)]

I hope I have been of some help.

-- Christopher P. Matthews

Please login and solve 5 problems to be able to post at forum