[Tutor] for loops

Alan Gauld alan.gauld at freenet.co.uk
Tue Apr 11 22:15:30 CEST 2006


>>   >>Write a Python program to print out the following  shape.
>>   >>You are expected to use two for loops (these must be nested) to solve 
>> this problem.
>>
>>   output:
>>   * * * * *
>>   *          *
>>   *          *
>>   * * * * *
>
> That looks a lot like homework.

I agree and very poor homework too.
I certainly wouldn't expect to use two for loops, I'd only use one.
(And that assumes the more general problem of drawing an
arbitrary sized square, for the specific case I'd use a single print
statement and triple quoted string!)

Any homework which implies that only one design is acceptable
is a bad assignment in my book!

> We generally try to stay away from doing the work for you :-)

But the advice stays good. Tell us how far you got and what's
sticking you and we will try to help...

Alan G
Author of the learn to program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld




More information about the Tutor mailing list