In Python append() method is used to add an item to the end of the list. It adds a single item to the existing list. On every append function call the length of the list increases by one.
Syntax of append() method
list.append(item)
Here, item is the required parameter, it is of any data type. This method returns the updated existing list.
This is following solution to create a string that contains a colon as a separator.
In the above code, we have taken a blank content list and appends the four elements by using append method. We have used join() method to add a colon as a separator.
Solution
In Python append() method is used to add an item to the end of the list. It adds a single item to the existing list. On every append function call the length of the list increases by one.
Syntax of append() method
list.append(item)
Here, item is the required parameter, it is of any data type. This method returns the updated existing list.
This is following solution to create a string that contains a colon as a separator.
Output of the above code
elephant:sparrow:eagle:tiger
In the above code, we have taken a blank content list and appends the four elements by using append method. We have used join() method to add a colon as a separator.
need an explanation for this answer? contact us directly to get an explanation for this answer