I have learned that I can use the so-called list comprehension to make python 'for loops' shorter if I want to create a list. For example, instead of writing:
b = []
a = [2, 3, 5]
for x in a:
b.append(x**2)
I can write my code like this:
b = [x**2 for x in a]
I was wondering how can I convert the below code to the second shorter format:
lst = [1, 2, 3, 3, 4, 5, 5]
u_lst = []
for x in lst:
if x not in u_lst:
u_lst.append(x)