I am on python 2.7 and Linux

I have the stdout in the below form , I need to write a function to get
hostname for the given id.


>>> stdout
'hostname-1 is array with id 1\nhostname-2 is array with  id 2\nhostname-3
is array with id 3\n'

def get_hostname(id)
       return id

what's a better option here

1. store it in list and grep for id and return
2. store it in dict as key and value i.e hostname = { 'hostname1': 1} and
return key
3. any other simple options.


Reply via email to