This is my first question ever - sorry if bit trivial
I wonder what is the difference (is there any?) between this two methods
Method A
animals = ['cat', 'dog', 'goldfish']
pets = animals[:]
animals.sort()
pets.append('donkey')
print(animals)
print(pets)
Method B
animals = ['cat', 'dog', 'goldfish']
pets = list(animals)
animals.sort()
pets.append('donkey')
print(animals)
print(pets)
In method A copy of list is created and assigned to new variable (pets)
In method B new list is created and assigned to pets?
(not sure if I'm right) Do we creating list in method A ?