Share your knowledge at the LQ Wiki.
 Home Forums HCL Reviews Tutorials Articles Register Search Today's Posts Mark Forums Read
 LinuxQuestions.org Invalid Syntax Error on Python Function
 Linux - Newbie This Linux forum is for members that are new to Linux. Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

 03-30-2013, 08:05 PM #1 antonia_alessandra LQ Newbie   Registered: Mar 2013 Posts: 2 Rep: Invalid Syntax Error on Python Function Hey guys, I have been trying to write a function in python and keep getting an invalid syntax error and I'm not sure why. This is my current code: Code: ```def aero_top(x): y =(0.102/0.20)*((0.29690*sqrt(x))-(0.126*x)- (0.35160*(x**2))+ (0.28430*(x**3))- (0.10150*(x**4))) if x = 1.0 y = 0.0 x = x/5. y = y/5. return (x,y,0.0)``` The error I keep getting is: Code: ```File "NACA_Aerofoil_Spyder.py", line 22 if x = 1 ^ SyntaxError: invalid syntax``` Any ideas?? Thanks.
03-31-2013, 01:17 AM   #2
rosehosting.com
Member

Registered: Jun 2012
Posts: 222

Rep:
Quote:
 Originally Posted by antonia_alessandra if x = 1 ^ SyntaxError: invalid syntax
Try using this code:

if x == 1:

1 members found this post helpful.
 03-31-2013, 02:38 AM #3 antonia_alessandra LQ Newbie   Registered: Mar 2013 Posts: 2 Original Poster Rep: That worked! Thank you! Any idea why I had to write it that way?
 03-31-2013, 02:49 AM #4 rosehosting.com Member   Registered: Jun 2012 Posts: 222 Rep: The Python language has many similarities to Perl, Java and C. However, there are some definite differences between the languages. Many Python constructs, like if, while, and for, require a terminating colon : . Also, '=' is the assignment operator while '==' is the 'is equal to' comparison operator. 1 members found this post helpful.

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is Off HTML code is Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Abakus Linux - Server 2 08-22-2012 05:03 AM donanap Linux - General 3 09-07-2011 09:33 AM cre84j Linux - Software 4 01-23-2011 04:46 PM Python_user Programming 2 09-06-2009 12:52 PM LinuxCrayon Programming 4 12-07-2007 09:11 AM

All times are GMT -5. The time now is 08:07 PM.

 Contact Us - Advertising Info - Rules - LQ Merchandise - Donations - Contributing Member - LQ Sitemap -