📜  从字符串中删除 n python 代码示例

📅  最后修改于: 2022-03-11 14:46:32.796000             🧑  作者: Mango

代码示例5
example_string = "Hello there"

def remove_chars(n, string):
    list_of_chars_in_string = [char for char in string] 
    
    for num in range(n):
        list_of_chars_in_string.pop() # Removes last n characters in string
    
    new_string = ''.join(list_of_chars_in_string)
    return new_string