나는 이렇게 학습한다/Algorithm & SQL

1218. Remove First and Last Character

daco2020 2022. 12. 18. 19:54
반응형

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: str, limit: int = 1):
    return s[limit:-limit]


반응형

'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글

1220. The 'if' function  (0) 2022.12.20
1219. Return the day  (0) 2022.12.19
1217. Regexp Basics - is it a digit?  (0) 2022.12.17
1216. Define a card suit  (0) 2022.12.17
1215. Is it even?  (0) 2022.12.15