The function I wrote below should assign a 4 digit unique id to the rows missing ids. What it does is, it first calculates all 4 digit permutations of numbers between 0 and 9. Then creates a list consisting of current 4 digit ids in the dataset. Afterwards detects the rows without ids. After detecting the rows without ids, we loop through the permutations and when we find one that is not already in the dataset we modify that row and assign that permutation as the id. However, when I submit my answer, I see that some rows have duplicate ids. Such as " The column `id`

has duplicated values: Example rows `1`

and `10`

with value `9876`

."

I can’t understand how this is happening. Can someone please help me out?

```
def clean_id_col():
listings = list(csv.reader(open('listings.csv')))
import itertools
permutation = list(itertools.permutations([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 4))
string_permutation = []
for perm in permutation:
number = ''
for integer in perm:
number = number + str(integer)
string_permutation.append(number)
unique_ids = []
for row in listings:
ids = row[0]
if ids:
unique_ids.append(str(ids))
for row in listings[1:]:
ids = row[0]
if not ids:
for number in string_permutation:
if number not in unique_ids:
row[0] = number
write_csv(listings)
```