LinkedIn Python Skill Assessment Quiz Answers

What is the proper way to write a list comprehension that represents all the keys in this dictionary?

Latest Update on 25th January, 2022 by Certification Course Answers

What is the proper way to write a list comprehension that represents all the keys in this dictionary?

fruits = {'Apples': 5, 'Oranges': 3, 'Bananas': 4}

  1.  fruit_names = [x in fruits.keys() for x]
  2.  fruit_names = for x in fruits.keys() *
  3.  fruit_names = [x for x in fruits.keys()]
  4.  fruit_names = x for x in fruits.keys()

Correct Answer:

  •  fruit_names = [x for x in fruits.keys()]

Latest Updates

No posts found in this category.