Format call with colon in Python?

In function “def gradient_descent” of “C1_W2_Linear_Regression.ipynb” there is a print call. What means the format call of “i:4”? I think it is not necessary. You could just write “i” because it will print 4 digits if there is such an integer (e.g. 1350 iterations).

print(f"Iteration {i:4}: Cost {float(J_history[-1]):8.2f}   ")

See also here.


That’s so that all those print statements line up consistently, whether i has 4 digits or fewer than 4 digits. Just to look cleaner.