Untitled

 avatar
unknown
python
13 days ago
447 B
8
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