I have defined one method and I tried to call it inside a constructor, However I am getting error "userDetailsValidation" is not defined, Even If I have defined it above the constructor. Here is my code:
class PythonAssignment:
FirstName = ""
LastName = ""
dateOfBirth = ""
def userDetailsValidation(fieldvalue, fieldName, database):
for entry in database:
if fieldName in entry and entry[fieldName] == fieldvalue:
return True
def printRequiredUserInfo(FirstName, fieldname, AccountNumber, Accountbalance, Database):
for entry in Database:
if fieldname in entry and entry[fieldname] == FirstName:
print(entry)
def __init__(self):
self.FirstName = str(input("Enter First Name").upper())
while True:
if (userDetailsValidation(FirstName, "FirstName", newSortedDatabase)) == True:
userDetails.append(FirstName)
break
else:
print(" First Name did not matched with the database")
FirstName = str(input("Enter First Name").upper())
userObject = PythonAssignment()