Feb-08-2020, 08:30 PM
f = open('cities.txt', r) while True: line = f.readline() print(line) if not line: break f.close()Your
readline()
needs to be inside the loop or it never changes. If it never changes then it can never be an empty line.
My Loop for printing text file goes to infinity
|
|
Messages In This Thread |
My Loop for printing text file goes to infinity - by Nomex - Feb-08-2020, 03:44 AM
RE: My Loop for printing text file goes to infinity - by michael1789 - Feb-08-2020, 04:30 AM
RE: My Loop for printing text file goes to infinity - by Nomex - Feb-08-2020, 04:43 AM
RE: My Loop for printing text file goes to infinity - by michael1789 - Feb-08-2020, 08:30 PM
RE: My Loop for printing text file goes to infinity - by snippsat - Feb-08-2020, 09:21 PM
RE: My Loop for printing text file goes to infinity - by michael1789 - Feb-08-2020, 10:12 PM
RE: My Loop for printing text file goes to infinity - by Nomex - Feb-10-2020, 01:42 PM
RE: My Loop for printing text file goes to infinity - by buran - Feb-10-2020, 03:13 PM
|
Possibly Related Threads… | |||||
Thread | Author | Replies | Views | Last Post | |
Printing During a Loop | apeltes | 16 | 5,405 |
Oct-21-2021, 12:19 AM Last Post: apeltes |
|
Help with for-loop printing. I want it to print only once. | blacklight | 2 | 7,047 |
Jun-26-2020, 02:23 AM Last Post: pyzyx3qwerty |
|
Convert text from an image to a text file | Evil_Patrick | 5 | 4,328 |
Jul-30-2019, 07:57 PM Last Post: DeaD_EyE |
|
reading text file and writing to an output file precedded by line numbers | kannan | 7 | 10,488 |
Dec-11-2018, 02:19 PM Last Post: ichabod801 |
|
Newly written .txt file not printing | Crackity | 11 | 6,123 |
Oct-20-2017, 06:43 AM Last Post: gruntfutuk |
|
Command line inputs not printing to Log File | ijosefson | 1 | 3,381 |
Oct-19-2017, 06:41 AM Last Post: buran |