Python Forum

Full Version: The list length should be 100 but it is more than 100
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I am trying to produce 100 different names (names should be unique) and I wrote this simple code:

import names
parties=[]
nss=100
while len(parties) < nss:
     for i in range(nss):
        rand_name = names.get_first_name(gender='female')
        if rand_name not in parties:
           parties.append(rand_name)
           
print(parties)
print(len(parties))
But I have more than 100 names at the end. What am I missing in this code?
okay. This for is not necessery here.
It is sorted out