1

I want to make a new string from an internal part of an old string, and when I know the length of the string I know I can do this:

newString = oldString[6:145]

This exludes the first and last chars from the old string when writing the newString. But is there a way to do this if i dont know the length of the string, like:

newString = oldString[6:len(oldString)-6]

Thanks.

1 Answer 1

4

Is this what you are looking for?

newString = oldString[6:-6]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.