[Tutor] First program

Andre Engels andreengels at gmail.com
Sat Mar 13 03:30:26 CET 2010

On Sat, Mar 13, 2010 at 3:11 AM, Ray Parrish <crp at cmc.net> wrote:
> Andre Engels wrote:
>> On 3/12/10, yd <ydmt923 at gmail.com> wrote:
>>>  else:
>>>    raise Exception('{0}, is not a valid choice'.format(choice))
>> This will cause the program to stop-with-error if something wrong is
>> entered. I think that's quite rude. I would change this to:
>>  else:
>>    print('{0}, is not a valid choice'.format(choice))
> Here's what I get from that, could you please explain why?

You're probably using Python 2.4 or 2.5; the .format method has been
introduced in Python 2.6, and is considered the 'standard' way of
working in Python 3. For older Python versions, this should read

print('%s, is not a valid choice'%(choice))

André Engels, andreengels at gmail.com

More information about the Tutor mailing list