0

Please help with translate this Python code I am trying to figure out the meaning of this code and could not end up with a conclusion... does anybody know how this single line code is like when it is not single lined.

data = [columns.get_text().strip() for columns in column]
write.writerow(data)

I thought it is translated as the code below, but it showed different value..

for columns in column:
        data = columns.get_text().strip()
        write.writerow(data)

please help...

1 Answers1

0

The equivalent of

data = [columns.get_text().strip() for columns in column]
write.writerow(data)

would be:

data = []
for columns in column:
    data.append(columns.get_text().strip())
write.writerow(data)
Jacob Celestine
  • 1,758
  • 13
  • 23