How to return a dictionary and several variables from a function in python?

I am trying to set up a function that records to 2 variables and a dictionary, the dictionar works but the two variables return the wrong things

mydict{}
fname = 0
lname = 0

def enterdetails(fname, lname):
    fname = input ("First Name: ");
    fnamedict = fname
    mydict['FirstName'] = fnamedict;

   lname = input ("Last Name: ");
   lnamedict = lname
   mydict['LastName'] = lnamedict;
   print(fname)
   print(lname)

   return mydict
   return (fname, lname)

fname, lname = enterdetails(fname, lname)
print(fname, lname)
print(mydict)

However the variables of fname and lname come out as FirstName and LastName respectively. How would I fix this?


You have two return statements, but only the first is returned. Instead, return all three variables together as a tuple:

def enterdetails(fname, lname):
    ...
    return mydict, fname, lname

mydict, fname, lname = enterdetails(fname, lname)
print(fname, lname)
print(mydict)