row_string = "" in the outer loop creates a new, empty string every time the outer loop runs.
So when the inner loop starts to run, the
row_string is an empty string. Now each time the inner loop runs, something gets added (appended) to that empty string, namely the value of
product casted into a string and a tab
\t. When the inner loop is finished, the whole string gets printed.
row_string = "" serves two purposes: first it creates an empty string so you have something to append to. And second it makes sure that every time the inner loop runs, a fresh string is used (so the outer loops are independent of each other)
solved In the following code how row_string = ” ” is working?