0

I have successfully iterated through a PHP array with Python, i'm stuck with trying to grab values properly in a interger dict

My code is like below :

from itertools import chain

listss = {0: {'value': 'Tasty'}, 1: {'value': 'Tasteless'}, 2: {'value': 'Overcooked'}, 3: {'value': 'Undercooked'}, 4: {'value': 'Fresh'}, 5: {'value': 'Not fresh'}}

a = ", ".join(x for x in chain(*listss.values()))

print(a)

Output:

value, value, value, value, value, value

I'm looking for this output:

Tasty,Tasteless,Overcooked,Undercooked,Fresh,Not fresh

Please help

Roshin Raphel
  • 2,612
  • 4
  • 22
  • 40
John Pham
  • 65
  • 6
  • i've also tried this from https://stackoverflow.com/questions/49639609/converting-dictionary-values-to-list-in-python – John Pham Sep 04 '20 at 09:23

1 Answers1

1

Is this okay?

from itertools import chain

listss = {0: {'value': 'Tasty'}, 1: {'value': 'Tasteless'}, 2: {'value': 'Overcooked'}, 3: {'value': 'Undercooked'}, 4: {'value': 'Fresh'}, 5: {'value': 'Not fresh'}}

a = ", ".join(x['value'] for x in listss.values())

print(a)