首页 > 其他分享 >Remove First and Last Character

Remove First and Last Character

时间:2023-03-15 22:33:42浏览次数:33  
标签:Last string Character Remove characters 字符串

Instructions
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. You don't have to worry with strings with less than two characters.
Solution

def remove_char(s):
    return s[1 : -1]

a_string[start : end] : 返回一个字符串类型,返回的数据是原字符串第2个字符倒数第2个字符之间所有字符组成的字符串

标签:Last,string,Character,Remove,characters,字符串
From: https://www.cnblogs.com/artwalker/p/17220459.html

相关文章