The problem:
Given a string called date that is in the form MM/DD/YYYY, write a function called date_extractor that takes date as an input and returns three values, month, day, and year.
For example, if date = '6/16/2006', the function should return multiple values in this form: ('6', '16', '2006').
But, when I try to check answer it say that it does not have “length”, I can understand that is trying to say that I am not giving the answer as a string, but I do not know how to fix it and what could I be doing wrong, I have also tried .append the splits into strings to see if it works but haven’t find a way that it completly works, I usually say that i am out of reach, when I try to append the year information.
You are not returning a single string (and the instructions don’t seem to want that anyway).
In your function, the variables day, month and year have strings assigned to them. But the return statement
return day, month, year
doesn’t concatenate/join them as a single string before returning. Since you are returning multiple values in a single return statement, so they are returned as a tuple.
In your original post, you were printing instead of returning. Also, the split method returns a list of strings. So, if you returned the whole list, the automated grader would probably reject the solution as it is likely expecting a tuple to be returned (based on the example in the instructions of your original post).
You could also have converted the list to a tuple explicitly before returning (but that decision depends on what you want to do in your function and what you find to be more readable),
def split_date(date):
return tuple(date.split('/'))
result = split_date("01/19/1998")
# OR you can unpack the returned tuple to different variables
month, day, year = split_date("01/19/1998")