473,405 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

keep getting Strange syntax error Help!!!!

Today I am going nuts. This is another one that is not working. It keeps giving me syntax error at highlighted line. No matter what I do I still have that error at the same line. It seems that my first input line has an error which gives me a error message at second line. I just do not know what is the error. Syntax???

Andy

Expand|Select|Wrap|Line Numbers
  1. def accountInfo(custName, accountNum, startingBalance, deposit, years):    
  2.     custName = (raw_input ("Please enter your name: ")
  3.     accountNum = int (raw_input ("Please enter your account number: ")
  4.     startingBalance = float (raw_input ("Please enter your starting balance: ")
  5.     deposit = int (raw_input ("Please enter amount you are depositing: ")
  6.     years = int (raw_input ("Please enter the years you are depositing the money: ")
  7.  
  8. def calculate(balance, newBalance):
  9.     balance = 0
  10.     balance += deposit    
  11.     count = 0
  12.     while count <= years:
  13.         newBalance = balance * (1 + interest)** years
  14.         newBalance += newBalance
  15.         print "Balance for the year " + count + " is " + newBalance
  16.  
  17.  
  18. #Main------------------------------------------------------------
  19.  
  20. print "Welcome to the First Charter Bank\n"
  21. accountInfo()
  22. calculate()
  23.  
  24.  
Dec 5 '06 #1
2 1953
bartonc
6,596 Expert 4TB
Please copy the whole error message here. Also, it wasn't CAPs that were the problem. use "/" instead or "\"
Dec 6 '06 #2
bvdet
2,851 Expert Mod 2GB
Today I am going nuts. This is another one that is not working. It keeps giving me syntax error at highlighted line. No matter what I do I still have that error at the same line. It seems that my first input line has an error which gives me a error message at second line. I just do not know what is the error. Syntax???

Andy

Expand|Select|Wrap|Line Numbers
  1. def accountInfo(custName, accountNum, startingBalance, deposit, years):    
  2.     custName = (raw_input ("Please enter your name: ")
  3.     accountNum = int (raw_input ("Please enter your account number: ")
  4.     startingBalance = float (raw_input ("Please enter your starting balance: ")
  5.     deposit = int (raw_input ("Please enter amount you are depositing: ")
  6.     years = int (raw_input ("Please enter the years you are depositing the money: ")
  7.  
  8. def calculate(balance, newBalance):
  9.     balance = 0
  10.     balance += deposit    
  11.     count = 0
  12.     while count <= years:
  13.         newBalance = balance * (1 + interest)** years
  14.         newBalance += newBalance
  15.         print "Balance for the year " + count + " is " + newBalance
  16.  
  17.  
  18. #Main------------------------------------------------------------
  19.  
  20. print "Welcome to the First Charter Bank\n"
  21. accountInfo()
  22. calculate()
  23.  
  24.  
Check your parentheses. They must balanced.

You have argument lists in your function definitions, but you are not passing arguments to the functions when they are called. Your functions may need to return someting back.

Call function with arguments:
Expand|Select|Wrap|Line Numbers
  1. calculate(balance, deposit, interest)
Assign variables to a function call that returns a list of values:
Expand|Select|Wrap|Line Numbers
  1. custName, accountNum, startingBalance, deposit, years = accountinfo()
Function that receives no argument but returns a list:
Expand|Select|Wrap|Line Numbers
  1. def accountInfo():    
  2.     custName = raw_input ("Please enter your name: ")
  3.     accountNum = int (raw_input ("Please enter your account number: "))
  4.     startingBalance = float (raw_input ("Please enter your starting balance: "))
  5.     deposit = int (raw_input ("Please enter amount you are depositing: "))
  6.     years = int (raw_input ("Please enter the years you are depositing the money: "))
  7.     return custName, accountNum, startingBalance, deposit, years
Notice the return statement. Check your parentheses. Return values to function calls where necessary. Pass arguments to functions where necessary. You are on the road to OOP.
Dec 6 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Vernon | last post by:
Hi anyone, This is my code. int num num = 0; for(int a=0; a<count; ++a){ if(current->transID==aNo) ++num; current = current->next;
8
by: Bob | last post by:
I tried this in <input name="some_name" type="text" value="" onChange="auto_select(0);"> but it gives a syntax error. var cb = this.form.name alert( "name=" + cb )
4
by: Dave | last post by:
Hi, I'm running Access '03, SQL SERVER 2k on Windows XP SP1. I've not got a ton of experience in writing UDF's for t-sql. In SQL Query Analyzer, I'm trying to write a user defined scalar...
0
by: CAIBird | last post by:
hi, i've been developing a webservice on machine A and one WebMethod of this webservice will connect to SQL Server2000 on machine B using a connect string defined in Web.config as below: <add...
1
mikeinspain
by: mikeinspain | last post by:
Hi Guys I am getting the following error: Parse error: syntax error, unexpected '}' in /home/9144/domains/cbweb.co.uk/html/propertyEnquiry.php on line 5 This is the referring PHP code... ...
8
by: illuzion | last post by:
ok I keep getting this error: Parse error: syntax error, unexpected T_VARIABLE in /home/illuzion/public_html/BAMF/contactus.php on line 38 and this error is possibly on other lines could...
5
by: Ty | last post by:
Syntax Error-Help!! My error "SQL0180N The syntax of the string representation of a datetime value is incorrect. SQLSTATE=22007" . I'm using yyyy-mm-dd. I can see the dates in a column on...
10
by: charmeda103 | last post by:
My program keeps getting me and error and i dont why here is the error message error C2061: syntax error: identifier 'infile' error C2660: 'ReadDate' : function does not take 6 arguments...
3
by: James Watson | last post by:
'Microsoft VB 6.3, Access 2002 'Syntax error in the INSERT INTO Statement when the query runs 'How can I make this work? Private Sub Command52_Click() On Error GoTo Err_Command52_Click ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.