def step_3(w):
 for (suffix, rules) in suffixes3:
  if w.endswith(suffix):
   for (A, B) in rules:
    if w.endswith(A):
     return ((R1(w).endswith(A) and (w[:(- len(A))] + B)) or w)
 return w

def step_3 ( w ) : for ( suffix , rules ) in suffixes3 : if w . endswith ( suffix ) : for ( A , B ) in rules : if w . endswith ( A ) : return ( ( R1 ( w ) . endswith ( A ) and ( w [ : ( - len ( A ) ) ] + B ) ) or w ) return w
step 3 replaces -ic .