Python only looping through the first 2 lines in a file -


i'm looping through file ips in it. first 2 lines looped through although program seems know there 6 in total.

here's code:

#!/usr/bin/python3 open('/path/to/ip/list.txt') file:   idx, ln in enumerate(file):     print(ln) 

here's output after running it:

$ ./script.py 6 172.217.6.110  31.192.120.36 

here contents of file:

$ cat list.txt 172.217.6.110 31.192.120.36 10.234.43.123 192.168.1.1 172.40.432.65 172.20.35.43 

i'm not sure what's going wrong. code seems consistent i'm seeing others write online. should next? have linux system , forcing use of python3 if has problem.

perhaps try:

with open('/path/to/ip/list.txt','r') file:   ln in file.readlines():     print(ln) 

test on local machine:

test on local machine


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -