r/pythonhelp • • Feb 19 '22

Python project of grade

It's pretty straightforward. Your goal is to create a function that removes the first and last characters of a string. You're given one parameter, the original string. The input will always be at least 2 characters.

def remove_char(s):

What do I have to do in this problem? Please I really need it.

0 Upvotes

3 comments sorted by

View all comments

1

u/[deleted] Feb 21 '22
def shorten_string(string: str) -> str:
    return string[1:-1]

This doesn't care about the length of the string provided in the call - will not fail even if zero length string is passed - but problem statement says you are guaranteed to be provided with at least min 2-character length string.