I would suggest you to use the below modified code. Even if you don't remove while name != 'QUIT', it would still work fine :-
def password():
import random
password = []
name = raw_input('Enter your name')
pn = raw_input('Enter your pets name')
bday = raw_input('Enter your birthday month')
date = input('Enter the date you were born')
while name != 'QUIT':
pw = random.sample(name,3)
password.extend(pw)
pw1 = random.sample(pn,3)
password.extend(pw1)
pw2 = random.sample(bday,3)
password.extend(pw2)
password = ''.join(password)
return('Your security code is', password + str(date))
modifications in detail :-
using raw_input instead of input removes the overhead of typing qoutes(') before entering string as name, pet name and month. Because, raw_input() takes the input in string format.
All your child lists (pw, pw1 & pw2) gives a new list. And you are appending these newly created lists to the parent list password. You have missed to append pw2. So at the end append makes the parent list password a list of 3 lists pw, pw1 & pw2.
password = [pw, pw1, pw2] # list of lists
So, then you have to traverse each list one by one to form the password. It adds unnecessary overhead. Instead of doing that, best way to use is extend instead of append. This will append the elements of the child lists (pw, pw1 & pw2) to the parent list password. So at the end, all your generated characters are in the parent list password.
Now the line password = ''.join(password), creates a string out of all the characters in the list. No need of traversing the list. But, your code was not concatenating the three lists anywhere. So it was simply returning three lists nested in one single list (in fact two list since, you had missed out appending pw2).
Then the return statement would have failed :-
return('Your security code is', password + date)
Because, date is an integer and the code is trying to add an integer with a string, which will throw TypeError. So modify it to str(date).
This step can be omitted, if you also append this date to the parent list password. Then the join statement would have taken care of adding it to the formed password. But for that, you have to input the date in string format :-
date = raw_input('Enter the date you were born')
or append it as a string like :-
password.append(str(date))
Then your code will be as follow :-
def password():
import random
password = []
name = raw_input('Enter your name')
pn = raw_input('Enter your pets name')
bday = raw_input('Enter your birthday month')
date = raw_input('Enter the date you were born') # Inputs the date in string format
while name != 'QUIT':
pw = random.sample(name,3)
password.extend(pw)
pw1 = random.sample(pn,3)
password.extend(pw1)
pw2 = random.sample(bday,3)
password.extend(pw2)
password.append(date)
password = ''.join(password)
return('Your security code is', password)
nameis only assigned once, before the loop. Thus if the loop starts it will never end.