[Tutor] Help needed

Andre Engels andreengels at gmail.com
Fri Apr 8 09:03:33 CEST 2011


On Fri, Apr 8, 2011 at 3:57 AM, Aaron Brown <brownam at gmail.com> wrote:
> I am in an online python class and am failing badly.  I am not sure where
> the problem is here but any insight would be great.
>
> def main():
>     while (True):
>         allowed = int(input("Please enter minutes allowed between 100 and
> 700: "))
>         used = int(input("How many minutes were used: "))
>         totalOver = used - allowed
>         totalDue = (64.95 + (0.15*totalOver))
>         if(totalOver > 0):
>             print("You were over your minutes by " + str(totalOver))
>         else:
>             totalOver = 0
>             print("You were not over your minutes for the month")
>             print ("Do you want to end program? Enter yes or no:")
>             toEnd = raw_input()
>             if toEnd == "yes":
>                 print("MONTHLY USE REPORT")
>                 print("Minutes allowed were " + str(allowed))
>                 print("Minutes used were " + str(used))
>                 print("Minutes over were " + str(totalOver))
>                 print("Total due is $ " + str(totalDue(totalOver))
>
> I keep getting a syntax error in a blank line at the bottom.  I have tried
> to end it with main() but it errors on the main as well?

If you get a syntax error, the problem almost always is in the line
shown or the line directly above it. A blank line at the end is not a
syntax error, so in this case it is the line above it:

print("Total due is $ " + str(totalDue(totalOver))

This line has three left brackets but only two right brackets. Add one
right bracket and your program should run (however, it will not work
correctly - in the above line you try to call totalDue, but it is a
number, not a function or method).

-- 
André Engels, andreengels at gmail.com


More information about the Tutor mailing list