Hi,
I have started learning Python a week ago (I have previous experience with C++ and Java) and stumbled over piece of code I have trouble to understand.
I would be thankful if someone could explain me the last line.
I have started learning Python a week ago (I have previous experience with C++ and Java) and stumbled over piece of code I have trouble to understand.
def power_set(l): if not l: return [[]] return power_set(l[1:]) + [[l[0]] + x for x in power_set(l[1:])]The code calculates the power set. For power_set({1,2,3,4}) the output is {{}, {1}, {2}, {1,2}, {3}, {1,3}, {2,3}, {1,2,3}, {4}, {1,4}, {2,4}, {1,2,4}, {3,4}, {1,3,4}, {2,3,4}, {1,2,3,4}}. While the if statement is clear, the last is not .
I would be thankful if someone could explain me the last line.