iterating over a list and printing

Bart Nessux bart_nessux at
Wed Feb 11 16:24:14 CET 2004

ip_list = []
inputFile = file('ips.txt', 'r')
for i in ip_list:
    print "/sbin/ifconfig %s netmask broadcast up" %i

The last line does not work. It prints the first part (/sbin/ifconfig), 
then the entire list of ips, then the second part (netmask 
broadcast up). Any ideas on how to fix this? The desired 
results are to print a line for each IP.

/sbin/ifconfig IP1 netmask broadcast up 
/sbin/ifconfig IP2 netmask broadcast up

More information about the Python-list mailing list