lower = ['a', 'b', 'c']
upper = [i.upper() for i in lower]
print(upper)
['A', 'B', 'C']
List comprehension is commonly used when we want to convert one sequence into another. In the above example, we convert the lower list/sequence of letters into a list of uppercase letters. The list comprehension is happening in line 2.
Learn Flask development and learn to build cool apps with our premium Python course on Udemy.