This could be an interesting error

Mark Lawrence breamoreboy at yahoo.co.uk
Mon Sep 1 01:21:14 CEST 2014


On 31/08/2014 23:42, Seymore4Head wrote:
> On Sun, 31 Aug 2014 22:38:12 +0100, Mark Lawrence
> Unnecessary brackets?
> I tried deleting the brackets and that doesn't seem to work.  I tried
> changing the brackets to parenthesizes and that didn't work.  Although
> I would prefer brackets to parenthesizes as you don't need shift to
> type them.
>
>>>               pigword = stem + prefix + "ay"
>>>               print ("Stem ",stem)
>>>               print ("Prefix",prefix)
>>>               print (pigword)
>>>               break
>>>       return (pigword)

These            ^       ^

>>
>> This is Python so please get rid of those unnecessary brackets.  Having
>> done that assume that you have an empty test so your loop never gets
>> entered, the local pigword never gets assigned before the return hence
>> your UnboundLocalError.
>>

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence




More information about the Python-list mailing list