Python Forum

Full Version: Assert Error: AssertionError
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi!

The function stergereTranzactie(list,zi) delete a number from a list.
The function testarestergereTranzactie() tests stergereTranzactie(list,zi).

How can I solve this error/How can I use "assert" in this situation?


def stergereTranzactie(list,zi):
    del(list[zi])

def testarestergereTranzactie():
    assert (stergereTranzactie([12, 13, 14, 15], 0)==[13, 14, 15])

def mainFunction():
    testarestergereTranzactie()
    
mainFunction()
Error:
Traceback (most recent call last): File "C:/Users/Petru/Desktop/test.py", line 12, in <module> mainFunction() File "C:/Users/Petru/Desktop/test.py", line 9, in mainFunction testarestergereTranzactie() File "C:/Users/Petru/Desktop/test.py", line 5, in testarestergereTranzactie assert (stergereTranzactie([12, 13, 14, 15], 0)==[13, 14, 15]) AssertionError
Thanks!
stergereTranzactie() does not return anythin (i.e. it returns None).
you want to return the list after you deleted the element.
Note that list is built-in function. NEVER use built-in functions, module or package names as variables
Ok!
Thank you man, appriciate it, now is ok :D