str () + slicing the list
A shortcut that can be applied without having to access every element of the list is to transform the whole list to a string, and then remove the starting and last characters of the list using the list slicing. It won’t work if the list contains a string. In this case, each element can be joined using
join () , as discussed in many other articles.
The original list is: [5, 6, 8, 9, 10, 21] List after removing square brackets: 5, 6, 8, 9, 10, 21