groceries.insert(len(groceries), 'milk')
stringA == stringB.capitalize()
temp = list(fruit) temp.sort() diet = ' + '.join(temp)
['Do', 'Re', 'Mi'].join('-')
An AttributeError occurs. The join method
cannot be invoked upon a list instance; it is a method of
the str class. A proper example of its usage is
'High' + 5
A TypeError occurs. There is no definition for adding a string and an integer.
['Do', 'Re', 'Mi'].insert('Fa')
A TypeError occurs. The insert method expects two parameters. The first must be an index into the list at which a new element is to be placed, and the second must be that new element. In this case, we have only sent the new element.
'hello'.remove('a')
An AttributeError occurs. A string does not support a method named remove.
list('hello').remove('a')
A ValueError occurs. Although the list supports the remove method, the particular value of the parameter was not found in that list.
firstIndex = groceries.index('milk')
secondIndex = groceries.index('milk', firstIndex + 1)
groceries.pop(secondIndex)