python - How can we add new list so that they are in the same row but different column with the dict in table html? -


here codes old list :

from collections import defaultdict  hello = ["hello","hi","hello","hello"]  def test2(strlist):     d = defaultdict(int)     k in strlist:         d[k] += 1     print('<table>')     in d.items():         print('<tr><td>{0[0]}</td><td>{0[1]}</td></tr>'.format(i))     print('</table>') 

and here new list:

hello2= ['bonjour','kiss'] 

expected output:

<table> <tr><td>hi</td><td>1</td><td>bonjour</td></tr> <tr><td>hello</td><td>3</td><td>kiss</td></tr> </table> 

i key keys , values in dict , have separate inputlist count keys.

something like:

keys = {"hello":{"postfix":"bonjour", "count":0},          "hi":{"postfix":"kiss", "count":0}}  frequencies = ["hello","hi","hello","hello"]  item in frequencies:     keys[item]["count"] += 1  print('<table>') k,v in keys.items():     print("<tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>"           .format(k, v["count"], v["postfix"])) print('</table>') 

and did homework...


Comments