Python String Lesson 5 Question

Python String Lesson 5

Hey everyone!
Quick question (hopefully). In the above lesson they are having us pull certain characters out of two different strings and concatenate them into a new string as a “temporary password”.

The lesson is having us use Len() to do this. But I disregarded that and didn’t use it, but got the same result. Even the lesson let me go ahead. So what was the point of using Len() in this situation, if it wasn’t necessary. I’ve provided my code and the “correct” code below.

My Code:

first_name = "Reiko" last_name = "Matsuki" def password_generator(first_name, last_name): pass_temp = first_name[-3:] + last_name[-3:] return pass_temp temp_password = password_generator(first_name, last_name)

Correct Code:

first_name = "Reiko" last_name = "Matsuki" def password_generator(first_name, last_name): temp_password = first_name[len(first_name)-3:] + last_name[len(last_name)-3:] return temp_password temp_password = password_generator(first_name, last_name)