-2

This is a json response i received.

  "allergens":[5 items
    0:"msg_free"
    1:"no_artificial_colors"
    2:"no_artificial_flavors"
    3:"no_artificial_ingredients"
    4:"gluten_free"
    ]

I want to get each description in allergens however when i try the following code i get something like this.

    allergies = response.json().get('allergens')

Outcome

['msg_free', 'no_artificial_colors', 'no_artificial_flavors', 'no_artificial_ingredients', 'gluten_free']

I would like to know how would i be able to print this out without it being in a list format without the brackets

1 Answers1

-1
your_list = ['msg_free', 'no_artificial_colors', 'no_artificial_flavors', 'no_artificial_ingredients', 'gluten_free']

to_be_filled = ", " # Comma separated is one option
to_be_filled.join(your_list) # The Argument could be any iterable
print(to_be_filled)
print(type(to_be_filled))

OUTPUT:

'msg_free, no_artificial_colors, no_artificial_flavors, no_artificial_ingredients, gluten_free'
<class 'str'>
JimShapedCoding
  • 849
  • 1
  • 6
  • 17