Example output
Bubble sort is an algorithm used to sort a list of items. In Python, the code for bubble sort looks like this:
```
def bubbleSort(list):
for i in range(len(list)):
for j in range(len(list)-i-1):
if list[j] > list[j+1] :
list[j], list[j+1] = list[j+1], list[j]
return list
```
Step-by-step explanation:
1. The bubbleSort() function is defined, with a parameter of a list.
2. A for loop is used to iterate through the list, starting from the first index.
3. An inner for loop is used to compare adjacent elements.
4. If the first element is greater than the second, they are swapped.
5. The outer loop is repeated until the list is sorted.
To apply this code to a list of integers, pass the list as an argument to the bubbleSort() function. For example, if the list is [3, 7, 2, 8, 4], the result would be [2, 3, 4, 7, 8].