Untitled
Anonymous
python
03/06/2025 5:12 PM
596 B
21
Indexable
if __name__ == '__main__':
filename = input('Enter a filename: ')
try:
with open(filename) as f:
variable=f.readlines()
hosts = [v.split()[0] for v in variable]
new_file = 'record_' + filename
with open(new_file, 'w') as nf:
nf.write('\n'.join(list([i + ' ' + str(hosts.count(i)) for i in set(sorted(hosts))])))
except FileNotFoundError:
print('File not found')Editor is loading...
Leave a Comment