The list length should be 100 but it is more than 100 - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: The list length should be 100 but it is more than 100 (/thread-34428.html) |
The list length should be 100 but it is more than 100 - quest - Jul-30-2021 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? RE: The list length should be 100 but it is more than 100 - quest - Jul-30-2021 okay. This for is not necessery here. It is sorted out |