May-20-2022, 05:55 PM
Usually you wouldn't bother to pre-initialize, especially if you didn't know the exact number beforehand. Instead, just process as necessary and append or add to a collection.
results = [] with open("mydata") as f: for line in f: # process each line as necessary. hostname = line.split()[0] results.append[hostname] # all the processed hostnames are now in the results list ...