Python does not loop over the file when piped in

I have a python file that's supposed to iterate via splitting lines but it only shows the first line and does not iterate.

Command that I run:

MINGW64 ~/Desktop (master)
$ cat input.txt | python deneme 16:20
1/30

Input.txt:

30 1
45 *
* *
* 19

Code: Deneme.py

#  Getting the list input
str_list = input().splitlines();

for i in str_list:
    minute = i.split()[0]
    hour = i.split()[1]
    print(hour + "/" + minute)

Solution:

import sys

for i in iter(sys.stdin.readline, ''):
   minute = i.split()[0]
   hour = i.split()[1]
   print(hour + "/" + minute)


from Recent Questions - Stack Overflow https://ift.tt/35VwtzS
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Hibernate Search - Elasticsearch with JSON manipulation

Spring Elasticsearch Operations