Beginner question: Indentation in Python menu

I am trying to write a menu that will read a system from the user. I managed to make the code for the input of the matrices work, and the menu itself, but when I try to put them together I keep getting an error message although they work separately.

This is what I have so far:

    ans=True
while ans:
    print ("""
    1) Ler matriz A e vetor B
    2) Imprimir na tela o sistema Ax=B
    3) Resolver o sistema Ax=B
    4) Sair
    """)
    ans=input("Choose option ") 
    if ans=="1": 
      n = int(input("Number of variables: "))
      matriz_A=()
      for i in range(n):
        b=()
        for j in range(n):
          j=float(input("Type entry ("+str(i+1)+")("+str(j+1)+") of matriz A: "))
        b.append(j)
        matriz_A.append(b)
        for i in  range(n):
          for j in range(n):
           print('(', end=" ")
          for j in range(n):
            print(matriz_A(i)(j),end=" ")
          print(')', end="")
          if i != n-1:
            print()
            print(')')

Before I was struggling with the indentation, but now the error message tells me that the list index is out of range.

Where am I making the mistake while putting the two codes together (menu and matrix) since they work fine on their own ?

Thank you in advance !