Skip to content

Instantly share code, notes, and snippets.

@aananya27
Created May 5, 2019 17:33
Show Gist options
  • Save aananya27/d8ae83fa4fc4bd1fc1607c1f7ab35ca1 to your computer and use it in GitHub Desktop.
Save aananya27/d8ae83fa4fc4bd1fc1607c1f7ab35ca1 to your computer and use it in GitHub Desktop.
Finding Gold Sequentially
import collections
from pprint import pprint
Miners = collections.namedtuple('Miners',[
'name',
'age',
'specialisation'
])
Miners = (
Miners(name = 'Blake', age = '43', specialisation = 'Excavating'),
Miners(name = 'Stephen', age = '27', specialisation = 'Surface mining'),
Miners(name = 'Adam', age = '26', specialisation = 'Subsurface mining'),
Miners(name = 'Joseph', age = '29', specialisation = 'Surface mining'),
Miners(name = 'Joe', age = '28', specialisation = 'Subsurface mining'),
Miners(name = 'Michael', age = '32', specialisation = 'Excavating'),
Miners(name = 'Jeff', age = '27', specialisation = 'Excavating'),
)
def gold_diggers(gm):
return {'name':'Mr.'+gm.name , 'who is': gm.age , 'working currently on': gm.specialisation + " gold " }
gold_miners = tuple(map( gold_diggers, Miners ))
pprint(gold_miners)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment