Creating Dictionaries To List Order Of Ranking
I have a list of people and who controls who but I need to combine them all and form several sentences to compute which person control a list of people. The employee order comes fr
Solution 1:
from collections import defaultdict
controls = defaultdict(list)
with open('data.txt') as file:
for line in file:
controller, controlled = line.strip().split(' controls ')
controls[controller].append(controlled)
print 'employee order:'
for controller, controlled in controls.iteritems():
if len(controlled) > 1:
conjoined = ', '.join(controlled[:-1])
conjoined = '{} and {}'.format(conjoined, controlled[-1])
else:
conjoined = controlled[0]
print '{} controls {}'.format(controller, conjoined)
![How To Access External Javascript Files Through Jinja[flask]?](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9tiKSsIecmF9YV-UaFm-n83unO7yEge1GuDO54V-enDCFy7tLsPAX8qrN4vCGUrwDr50gJMNuHia9IEYUi04TH4ghvsJEHXoPX4xussxFYp-WhNtQZBai5BmuYxmAy3TyL4qn9Cmr2kA/w192-h108-n-k-rw-no-nu/nomage+%25281%2529.png)
Post a Comment for "Creating Dictionaries To List Order Of Ranking"