So here is my code:
def formateUserData(FirstName = None, MiddleName = None, LastName = None, DOB = None, Gender = None):
formatedUserData = {}
dataFieldKeys = ['First Name', 'Middle Name', 'Last Name', 'DOB', 'Gender']
dataFieldValues = [FirstName, MiddleName, LastName, DOB, Gender]
for key, value in zip(dataFieldKeys, dataFieldValues):
if value: formatedUserData[key] = value
return formatedUserData
As you can see, the keyword arguments has to be repeated 3 times (first in line 1, second in line 3 and third in line 4). Is there a way I could do the same thing without by just storing the keyword arguments once? Maybe by using some way to iterate through the keyword arguments if that possible? BTW, I'm looking to not use **kwargs.