-2

I can't find the code to assign a string to a list and then name it.

The question states: Now split some_string by commas and assign the result to a list named mammals. Print mammals to verify that your split worked correctly.

some_string = "cat,dog,bear,chipmunk,squirrel,bat,groundhog"

print(some_string)
  • By google searching "Python split", I get [this](https://www.w3schools.com/python/ref_string_split.asp), it should be able to help you – jeffng50 Oct 25 '19 at 04:32

2 Answers2

0

What they're asking you to do is:

mammals = some_string.split(',')
print(mammals)

This way mammals becomes a list named mammals and = performs the assignment.

ashiswin
  • 637
  • 5
  • 11
0
>>> mammals = some_string.split(",")
>>> print(mammals)
['cat', 'dog', 'bear', 'chipmunk', 'squirrel', 'bat', 'groundhog']
Banghua Zhao
  • 1,518
  • 1
  • 14
  • 23