[Tutor] syntax error
Steven D'Aprano
steve at pearwood.info
Mon Sep 14 20:29:06 CEST 2015
On Mon, Sep 14, 2015 at 01:20:55PM -0400, Sarah 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
The above should be fine when saved and run from a .py file, but at the
interactive interpreter, you need to leave a blank line after functions.
Try leaving a blank after the print(...) line and before main().
--
Steve
More information about the Tutor
mailing list