What does this code below?



Can anyone here tell me what does zero in the code below? (In my return statement)

parties=['Tea Party', 'Coffee Party', 'Milk Party','House Party', 'Beach Party']
def initElection(parties):
    return [[0 for i in range(len(parties)) for j in range(DISTRICTS)]]


lets do a regular for loop which adds to a list:

example = []
for i in range(25):

this would be the same as:

example = [0 for i in range(25)]

i on purpose used zero in both cases, so the 0 is what you are append to list (see the similarity between the two programs)


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.