[Tutor] range question

Joel Knoll mindarson at live.com
Thu Sep 22 16:27:59 CEST 2011


Given a range of integers (1,n), how might I go about printing them in the following patterns:
1 2 3 4 ... n2 3 4 5 ... n 13 4 5 6 ... n 1 2 
etc., e.g. for a "magic square". So that for the range (1,5) for example I would get
1 2 3 42 3 4 13 4 1 24 1 2 3
I just cannot figure out how to make the sequence "start over" within a row, i.e. to go from 4 down to 1 in this example. 
I have been grappling with this problem for 2.5 days and have gotten nowhere!    		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110922/0def7bb9/attachment.html>


More information about the Tutor mailing list