FAQ: Introduction to Strings - More and More String Slicing (How Long is that String?)


#1

This community-built FAQ covers the “More and More String Slicing (How Long is that String?)” exercise from the lesson “Introduction to Strings”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Computer Science

FAQs on the exercise More and More String Slicing (How Long is that String?)

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!


#4

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()


#5

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


#6

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.


split this topic #7

4 posts were split to a new topic: And yet again i’m here with bugs…