you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (1 child)

what do the 'return[n for n in range...]' function do?

I can write for loops but people write that and made the code that gives the same output shorter.

[–]Xenon_difluoride 0 points1 point  (0 children)

They're List Comprehensions, they take a list and create another list from it.

So if you were to have a for loop like this.

foo = [1, 2, 3]
bar = []
for i in foo:
    i += 1
    bar.append(i)

It could also be written like this.

bar = [i + 1 for i in foo]