Here is one approach.
import math
TOL = 1.e-10
# Acid dissociation constant, acid concentration (M)
Ka, c = 1.78e-5, 0.01
Hp = 0.
while True:
lastHp, Hp = Hp, math.sqrt(Ka * (c - Hp))
if abs(lastHp - Hp) < TOL:
break
pH = -math.log10(Hp)
print('[H+] = {:g} M, pH = {:.2f}'.format(Hp, pH))
For a 0.01 M solution of acetic acid, the output is:
[H+] = 0.000413094 M, pH = 3.38