Python Forum
storing lines from stdin in a list
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
storing lines from stdin in a list
#1
Hello All,
I am new to phython, so need your help.

My requirement is as below:

I will be getting inputs from stdin. The first line of input contains 2 space separated integers;N - the number of lines in the game and M - the number of characters in the lines.N lines follows. The ith of these lines contains a binary string of length M.

Constraints
1 <= N <=20
1<= M <= 20

Result :

Input

3 3
111
010
001

I want to arrange it in a list as ['111','010','001'] and then it should be sorted and result should be ['001','010','111'].

Please help.
Reply


Messages In This Thread
storing lines from stdin in a list - by bghosh - May-02-2018, 12:57 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  When is stdin not connected to a tty, but can still be used interactively? stevendaprano 1 1,040 Sep-24-2022, 05:06 PM
Last Post: Gribouillis
  STDIN not working H84Gabor 3 3,647 Sep-06-2021, 08:10 AM
Last Post: H84Gabor
  Iterate 2 large text files across lines and replace lines in second file medatib531 13 6,000 Aug-10-2020, 11:01 PM
Last Post: medatib531
  how do i get rid of next lines in my list() ironpotatoe58 10 4,054 Mar-31-2020, 03:57 AM
Last Post: SheeppOSU
  How to read a file using stdin? pyth0nus3r 1 2,872 Aug-24-2019, 01:14 AM
Last Post: Larz60+
  What is the sys.stdin.isatty() command? pyth0nus3r 2 11,544 Aug-22-2019, 04:37 PM
Last Post: pyth0nus3r
  getting error "exec_proc.stdin.write(b'yes\n') IOError: [Errno 32] Broken pipe" Birju_Barot 0 2,967 Jul-23-2019, 11:50 AM
Last Post: Birju_Barot
  is it safe to close stdin Skaperen 1 2,699 Apr-04-2019, 06:57 AM
Last Post: Gribouillis
  Need help with reading input from stdin into array list Annie123 2 5,105 Mar-24-2019, 01:19 PM
Last Post: Annie123
  25 blank lines in my sorted_fruits output list! raven61 7 4,326 Aug-09-2018, 11:30 PM
Last Post: raven61

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020