The
break
statement immediately exits the "closest" loop: if you are have two nested loops, then
break
inside the inner oen exist from that loop only, and continues from the first lane of code after it rather than exiting from both.
So your code after the break:
print(area_of_triangle(base_val, height_val))
break
attempts += 1
will never, ever get executed. Which doesn't matter too much in this case, because the loop will always exit immediately if the base is less than the height.
What you need to do is move the line:
attempts += 1
outside the
if
and add code to check it to the
else
code.