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?
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?
+ 10
perkins royal , i have made a try, you can find the code in the file.
https://code.sololearn.com/ch56jnEGK6ef/?ref=app
+ 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.
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
0
@Russ I am a beginner in python so not really sure how we use. I'll give a try to make this work.