string - Python stdin, readlines. change output order -
string - Python stdin, readlines. change output order -
i working mac , have question python look. using .txt file called rectangle.txt , within file looks this:
abcde fghij klmno
i need read these in using stdin. need programme to:
afk bgl chm din ejo
so far, have programme reads lines , splits them , prints them out. code edited
so when changed code this: line in sys.stdin.readline(): ls1 = line print ls1
i received list:
a b c d e
so need loop through other ones, can't figure out
i running function command line:
python rectangle.py < rectangle.txt
i trying larn of this, instead of giving me answer, help explain me, in way can understand.
also, in add-on .txt file input. programme test these inputs:
123 456 789
and
a b c
all doing same thing above. give thanks 1 time again in advance helping me. have been working on hours , can't seem figure out.
i'm assuming input in each line has same length.
in case have list of input strings , length of 1 of these strings loop.
["abcde", "fghij", "kilmn"] here here notice pattern of first character each string? "a" + "f" + "k".
python string for-loop stdin readlines
Comments
Post a Comment