Python Forum
syntax error, and call functions.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
syntax error, and call functions.
#1
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()
Reply
#2
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.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#3
(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]
Reply
#4
(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
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Shocked School project -- need help with it it says syntax error XPGKNIGHT 6 3,309 Aug-11-2022, 08:43 PM
Last Post: deanhystad
  I'm getting a syntax error very early on in my code and I can't quite figure it out. liloliveoil 1 1,997 Oct-30-2020, 05:03 AM
Last Post: deanhystad
  Unspecified syntax error hhydration 1 2,002 Oct-25-2020, 10:45 AM
Last Post: ibreeden
  Annuity function for school - syntax error peterp 2 1,966 Oct-12-2020, 10:34 PM
Last Post: jefsummers
  How to call self into other functions Drax_TheViper 1 1,624 Jun-30-2020, 01:10 PM
Last Post: pyzyx3qwerty
  Invalid syntax error, where? tucktuck9 2 3,417 May-03-2020, 09:40 AM
Last Post: pyzyx3qwerty
  Raise an exception for syntax error sbabu 8 3,140 Feb-10-2020, 01:57 AM
Last Post: sbabu
  syntax error: can't assign to operator liam 3 4,037 Jan-25-2020, 03:40 PM
Last Post: jefsummers
  Self taught , (creating a quiz) syntax error on my array DarkAlchemyXEX 9 4,239 Jan-10-2020, 02:30 AM
Last Post: ichabod801
  If Statements and Comparisons returns a syntax error DarkAlchemyXEX 2 2,432 Jan-02-2020, 01:25 PM
Last Post: DarkAlchemyXEX

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020