[8 kyu] Remove First and Last Character

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):
    new_s = ""
    new_list = []
    for letter in s:
        new_list.append(letter)
    del new_list[0],new_list[-1]


    for letters in new_list:
        new_s += letters
    return new_s
    #your code here
发布了16 篇原创文章 · 获赞 0 · 访问量 47

猜你喜欢

转载自blog.csdn.net/HM_773_220/article/details/104771919