Python Forum

Full Version: syntax error, and call functions.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
First thing is first this program is meant to convert feet into inches. my first problem was that past the intro, I forgot to call the rest of the functions, so I just want to check and see if how I have it set up to call the rest of the functions will work. 
def main():
    #variables
    feet = 0
    inches = 12
    feetInches = 0
    intro()

#intro
def intro():
    print ("This program will help you convert how ever many feet you have into inches")
    getfeet()

#main calculation
def getFeet(feet):
    feet = input("How many feet do you have?")
    print (feet)
    inchesCalculation()

def inchesCalculation(feet, inches, feetInches):
    feetInches = feet * inches
    display()

def display(feet,feetInches):
    print ("There are " feetInches "inches in " feet "feet")  #here at feetInches I am getting a syntax error and I don't understand why.

main()
What do you get when you run your code? Does it work, or do you get errors? If you get errors, and you need help resolving them, post the entire Traceback (between the error code tags) and we will be glad to assist you.
(Mar-23-2017, 03:01 PM)sparkz_alot Wrote: [ -> ]What do you get when you run your code? Does it work, or do you get errors? If you get errors, and you need help resolving them, post the entire Traceback (between the error code tags) and we will be glad to assist you.

[Image: eb48f7a1f26a85da666beb4ebf7ae2cb.png]
(Mar-23-2017, 02:54 PM)Ayiden Wrote: [ -> ]print ("There are " feetInches "inches in " feet "feet")

Please do not post images of your code.  As to this particular error, you are getting it because it is not formatted correctly. A better way would be:
print ("There are {} inches in {} feet".format(feetInches, feet))    # Notice the use of the curly braces