dimanche 4 septembre 2016

Function argument tested for a list (data type)property

Please how can I test that n will only be for lists.(so that I can pass a unnittest for only lists allowed) I need help guys I am getting frustrated.

 def  twist_data(n):

      n=list(n)

      a=[]

      b=[]

     for i in n:

         if i<=0:
             a.append(i)

         if i>0:
             b.append(i)

    n=[len(a),sum(b)]
    return n




 gum= [2,4,5,-6,-7,]
 print (twist_data (gum))

Aucun commentaire:

Enregistrer un commentaire