```py import random import string def newMember(): newID = "" membersDatabase = open("members.txt", "a") name = input("Please enter your first and last name: ") name = name.split() firstName = name[0] lastName = name[1] id = getNewID(newID) for line in membersDatabase: if firstName and lastName in line: print("You already have a membership with us. Please login instead") print(f"Welcome to the Rock Climbing Center, {firstName}, your Center ID is {id},. Note it down in a secure place.") def getNewID(newID): length = 5 newID = "".join(random.choices(string.digits, k=length)) return newID newMember()``` How do I ensure that a unique ID is generated everytime, and if it isn't, how would i keep generating a new one until it is unique?
Do you need to generate the ID or like this, or can you just use a different way? Brute forcing this is not a good solution.