[Tutor] broken script - curiouser and curiouser

Alan Gauld alan.gauld at btinternet.com
Thu Jul 7 01:48:24 CEST 2011


"Lisi" <lisi.reisz at gmail.com> wrote 

>>  :   File "ex26.py", line 10
>>  :     def print_first_word(words)
>>  :                               ^
>>  : SyntaxError: invalid syntax
>>  : lisi at Tux:~/Python/LearnPythonTheHardWay$
>>
>> Look at the error.  Look at the error carefully.
>>
> I could see nothing that was different.

The error report says you had no colon in your code.
Python couldn't see it...

Are you sutre you didn't add it before posting but 
after running the code?

Or are you testing it by impotrting a module? 
In that case the interpreter may still be using 
the old version because you haven't reloaded 
the updated version?

> Yes - it was one of the first things I looked for when 
> the error came up (that and check that the brackets 
> were right).  It was there in what seemed to me 
> to be the right position.

In that case I suspect the module theory.
How are you running the code?

> In the end, having tried absolutely everything else 
> I could think of, and given that the error arose at 
> the closing bracket at the end of line 10, I 
> tried the only thing I could remotely think of that 
> I hadn't tried and put a space in between the 
> second bracket and the colon - and the wretched thing 
> ran.  

As you know that shouldn't have made any difference.
Did you try going back and removing the space again 
and see if the error came back?

> You could obviously see something wrong 

The posted error report had no colon.

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




More information about the Tutor mailing list