Learn practical skills, build real-world projects, and advance your career
Created 3 years ago
# Comprehensions
# Facts: 👉 One liner Expressions
# Motto: 👉 Do More with Less lines of CODES.
# Advantages : 👉 Fast Development/ Enhanced Problem Solving/ increased
# Productivity , improved code readability.
# ⚡️ Comparision
# let us say we want to find the squares of numbers between 1 an 10
# General Programming🏋️♂️
sqr_list=[]
for i in range(1,11):
sqr_list.append(i**2)
print(sqr_list)
[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
# Comprehension 😎
[x**2 for x in range(1,11)]
[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]