0

How to break the line after finding first specific string in a zip files using python?

Hello, I am trying to find the word 'python' in a zip file and print the line which contains 'python' . After printing the first line which contains 'python' I wanted to break the line. Here is the code I have....https://code.sololearn.com/c4VC513ODWoo/#py With this All the lines with python are printing and then breaking the loop. However, I just want only one line how do I break it after one line?

30th Oct 2020, 3:39 PM
perkins royal
perkins royal - avatar
5 Respuestas
+ 11
perkins royal , sounds interesting, but i need to get some more information. What do you mean by saying "... how do i break it after one line...?" Do you want to terminate the program when the word you searched for was printed?
30th Oct 2020, 4:31 PM
Lothar
Lothar - avatar
+ 10
perkins royal , i have made a try, you can find the code in the file. https://code.sololearn.com/ch56jnEGK6ef/?ref=app
30th Oct 2020, 7:31 PM
Lothar
Lothar - avatar
+ 1
perkins royal Seems strange that the loop is still continuing after the break command. Maybe you could try putting this into a function, and change break into return.
30th Oct 2020, 4:37 PM
Russ
Russ - avatar
0
@Lothar after printing the first line that contains "python" from each file I want to break the loop. Which means I just only need to print first line from each file
30th Oct 2020, 5:06 PM
perkins royal
perkins royal - avatar
0
@Russ I am a beginner in python so not really sure how we use. I'll give a try to make this work.
30th Oct 2020, 5:08 PM
perkins royal
perkins royal - avatar