-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?

2
  • 1
    Your indentation is soo off Commented Jun 30, 2017 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 Commented Jun 30, 2017 at 22:52

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.