I am trying to WRITE A FUNCTION to change the every instance in a list of tuples. Basically i need to convert the every instance of the list from ('value', number, 'value') to Arc('value', number, 'value')
Input: [('root', 1, 'a'), ('b', 0.0, 'root'), ('b', 2, 'c'), ('a', 5, 'd'), ('b', 7, 'a')]
def Convert(t):
t1=('head', 'weight', 'tail')
t2=namedtuple('Arc', (t1))
return t2
Required Output: [Arc('root', 1, 'a'), Arc('b', 0.0, 'root'), Arc('b', 2, 'c'), Arc('a', 5, 'd'), Arc('b', 7, 'a')]