-2
j = True
  while j == True:

area = raw_input("Elije la figura geometrica para calcular su area 
 \nCuadrado=1 \nTriangulo=2 \nCirculo=3\n")

if area == 1 :
 acuadrado()

the problem is in the area.It is something in the syntax?

  • 1
    Your indentation is soo off – Andrew Li Jun 30 '17 at 21:50
  • Fix question formating, provide traceback, explain what you are trying to do and what you are struggling with and provide full code. Without that nobody can help you. **and please check that [how to ask question](https://stackoverflow.com/help/how-to-ask)** – Arount Jun 30 '17 at 22:52

1 Answers1

0

raw_input in python2.x returns a "string" representation of the users input. Your wanting to do numerical comparison on the input, so you'll want to cast the area variable to an integer (int) before performing the comparison. Something like the following:

area = int(raw_input("Elije la figura geometrica..")

or

area = raw_input("Elije ...")
area = int(area)

then you can compare int values:

if area == 1 :
        acuadrado()

etc...

altogether something like this might help you get along:

def acuadrado():
    print 'acuadrado'

def atriangulo():
    print 'atriangulo'

def acirculo():
    print 'acirculo'


j = True

while j == True:

    area = raw_input("Elije la figura geometrica para calcular su area \nCuadrado=1 \nTriangulo=2 \nCirculo=3\n")

    area = int(area)

    if area == 1 :
        acuadrado()
    elif area == 2:
        atriangulo()
    elif area == 3:
        acirculo()
    else:
        print 'nada'
        j = False

Also see How can I convert a string to an int in Python?

Hope that helps.