case do problem

MRAB python at mrabarnett.plus.com
Wed Mar 3 15:45:06 CET 2010


Gregory Ewing wrote:
> Alf P. Steinbach wrote:
>> * Tracubik:
>  >
>>> iterations=0;
>>> count=0;
>>> REPEAT;
>>>   iterations = iterations+1;
>>>   ...
>>>   IF (genericCondition) THEN count=count+1;
>>>   ...
>>>   CASE count OF:
>>>     1: m = 1
>>>         2: m = 10
>>>         3: m = 100
>>
>> Uhm, is this syntactically valid Pascal? As I recall, every Pascal 
>> construct was delimited in some way.
> 
> I think it's okay. Pascal's control structures such as
> if-then and while-do mostly take single statements and
> didn't have an ending keyword. If you want multiple
> statements in the body you have to put begin-end around
> them.
> 
> Putting a semicolon after REPEAT is stylistically a
> bit odd, but it's not wrong.
> 
There shouldn't be a colon after the 'OF', and the cases themselves
should be separated by semicolons (the case-statement itself ends with
'end').



More information about the Python-list mailing list