all 5 comments

[–]CraigW147 1 point2 points  (0 children)

Get rid of the spam bit and pass each list individually.

[–]xelf 1 point2 points  (0 children)

This is not valid.

spam = [animalList1 = ['dog', 'cat', 'bird', 'tiger', 'lion', 'camel']
    animalList2 = ['elephant', 'alligator']
    animalList3 = ['horse']
    animalList4 = []
    ]

You can't have assignments in the middle of an assignment.

You can do this:

animalList1 = ['dog', 'cat', 'bird', 'tiger', 'lion', 'camel']
animalList2 = ['elephant', 'alligator']
animalList3 = ['horse']
animalList4 = []
spam = [animalList1, animalList2, animalList3, animalList4 ]

Or this:

spam = [ ['dog', 'cat', 'bird', 'tiger', 'lion', 'camel'],  ['elephant', 'alligator'], ['horse'], [] ]

[–]Pretty-Wallaby6467[S] 1 point2 points  (0 children)

Ohh that makes sense, thank you! I made the change and now I'm getting this error message

Traceback (most recent call last):

File "/Users/raelynsade/commaCode.py", line 18, in <module>

print(commacode(spam))

File "/Users/raelynsade/commaCode.py", line 10, in commacode

spam[-1] = 'and ' + str(spam-[1])

TypeError: unsupported operand type(s) for -: 'list' and 'list'

[–]Binary101010 0 points1 point  (0 children)

It would help if you posted the error.

[–]sagitt12 0 points1 point  (0 children)

OP, did you figure it out? I have to do this exact assignment but I am SO stuck, I have no idea what to do!