Could this be solved just using [-3:]?

The solution to the answer is this:
last_three_letters = string_name[len(string_name)-3:]

but I was wondering if there is a reason to write out that full argument or wouldn’t it be easier to just use string_name[-3:]

I’m probably overthinking it. I’m just not sure if one way is better or if they’re just making an example how to use len()

1 Like

Yes, though it is good to understand the full relationship to len() so it is taught before string slicing.

1 Like

Thanks for the help. The next section had actually explained string_name[-3:] and I think that section was just giving an example of how to use len(). I had been doing the data science path and already learned about it. I’m doing the computer science path now to get a better understanding of python so it’s a nice review.

1 Like