Python Basics
Refer the Python basics from the post – https://topguides.in/2023/03/24/python-installation
List Comprehension

In the above example, “for” loop is enclosed inside square brackets (the output will be a list),
and “for” loop is followed by “if” condition. Then the result “i” times “i” produce a square of “i”.
Wider User case
Simple JSON input structure
items = [
{‘name’ : ‘desktop’, ‘cost’ : 1000},
{‘name’ : ‘laptop’, ‘cost’ : 2000},
{‘name’ : ‘keyboard’, ‘cost’ : 200}
]
Extract product names from the above “items” and produce the output in a list format


In the above method without list comprehension, user to create an empty list and append the result of each iteration.
Using List Comprehension

