I currently have the function
def ndfa_as_str(ndfa: {str: {str: {str}}}) -> str:
ndfa_str = ""
sortedfa = sorted(ndfa.keys(), key=lambda x: x.lower())
for i in sortedfa:
ndfa_str += (" {} transitions: {}".format(i, list(sorted(ndfa[i].items()))) + "\n")
return ndfa_str
ndfa = {
'end': {},
'start': {'1': {'start'}, '0': {'near', 'start'}},
'near': {'1': {'end'}}}
my function returns:
" end transitions: []\\n near transitions: [(\'1\', {\'end\'})]\\n start transitions: [(\'0\', {\'near\', \'start\'}), (\'1\', {\'start\'})]\\n"'
however I am looking to return:
" end transitions: []\\n near transitions: [(\'1\', [\'end\'])]\\n start transitions: [(\'0\', [\'near\', \'start\']), (\'1\', [\'start\'])]\\n"'
where the sets are lists instead.
What's the simplest way I could do this?