How can I write this code in one-line?
aa = []
for s in complete:
aa.append(s)
I know there are several solutions. I would really appreciate if you could write them down. Thanks!
List comprehensions are awesome:
aa = [s for s in complete]
aa = [for s in complete]aa = completeI like to do such things with a list comprehension:
aa = [s for s in complete]
Though, depending on the type of complete, and whether or not you want to use package like numpy there may be a faster way, such as
import numpy as np
aa = np.array(complete)
I'm sure there are many other ways as well :)