<eternaltheft <at> gmail.com> writes: > > Hi guys, I'm having a lot of trouble with this. > > My understanding of python is very basic and I was wondering how I can return this table as a list of lists. > > 1 2 3 4 5 > 3 4 5 6 > 5 6 7 > 7 8 > 9 > > The function is > def Table(n): > Then how would I make it that when the value of n is 4 it returns [[1, 2, 3], [3, 4], [5]]. > > Thank you >
First of all, state your question precisely! I have no idea why with n=4 you would want to return that! Second, the solution of this sort of problem lies in list comprehensions combined with range(). Read up on those topics! Especially comprehensions are so fundamental to the language that you have know about them before you embark on any serious programming efforts. Best, Wolfgang -- http://mail.python.org/mailman/listinfo/python-list