Practicing Python (using Codewars)

I'm using Codewars as means of practicing what I've learned and how I apply it. However I encountered a challenge where I passed the test, but there's an error?

I don't see anywhere I can ask for help if I get stuck there. If I just copy and paste everything here should my code work for anyone to help me debug?

6 comments · 100% upvoted · other discussions

comments

Ben_HH [OP]

Objective: Remove n exclamation marks in the sentence from left to right. n is positive integer.

def remove(s, n):
    "Remove each '!' in the provided argument `n` number of times"

    removal_count = 0
    characters = list(s)

    while removal_count < n:
        position = characters.index("!")
        del characters[position]
        removal_count += 1

    return ''.join(characters)

Here are the tests for this challenge:

test.describe("Example Tests")

tests = [
    #[[input], [expected]],
    [["Hi!",1] , "Hi"],
    [["Hi!",100] , "Hi"],
    [["Hi!!!",1] , "Hi!!"],
    [["Hi!!!",100] , "Hi"],
    [["!Hi",1] , "Hi"],
    [["!Hi!",1] , "Hi!"],
    [["!Hi!",100] , "Hi"],
    [["!!!Hi !!hi!!! !hi",1] , "!!Hi !!hi!!! !hi"],
    [["!!!Hi !!hi!!! !hi",3] , "Hi !!hi!!! !hi"],
    [["!!!Hi !!hi!!! !hi",5] , "Hi hi!!! !hi"],
    [["!!!Hi !!hi!!! !hi",100] , "Hi hi hi"],
]


for inp, exp in tests:
    test.assert_equals(remove(*inp), exp)
ASIC_SP

also, there is already a string method to do this, check https://docs.python.org/3/library/stdtypes.html#string-methods