[Tutor] Help needed
Alan Gauld
alan.gauld at btinternet.com
Fri Apr 8 09:05:26 CEST 2011
"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.
When posting always include the full error text since
it usually helps locate the precise location more clearly
than a verbal description or summary.
> def main():
> while (True):
How do you intend to exit?
I don't see any return or break statements?
But thats not the immediate issue....
> 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))
You don;t need to call str() because print can do that for you.
All you need is:
print("You were over your minutes by ", 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()
Most of the code looks like Python v3 but this line is from Pyhon
v2...
raw_input has been replaced by input() in v3.
However, that should generate a NameError not a SyntaxError.
> 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?
The only probblem that jumps out at me is the raw_input()
but that would not be a syntax error...
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list