On 14/09/15 19:25, Joel Goldstick wrote:
On Mon, Sep 14, 2015 at 1:20 PM, Sarah <soer...@gmail.com> wrote:

Hi
What's wrong with the following code?

def main()
        lunch = int(input('How many hours did you eat?'))
        cost = float(input('Enter the hourly cost: '))
        gross_cost = lunch * cost
        print('cost:$', format(cost, '.2f'), sep='')
main()


I get the error File "<Stdin>", line 6

Thanks, Sarah


You forgot the : after def main(...):

Also your print line is, I suspect, wrong.
I assume you want to print gross_cost not cost?

You could also use the format method of the string which
tends to be more flexible:

print('cost: ${:.2f}'.format(gross_cost))

hth
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to