## Posted By

a7xrturo on 11/27/13

# Latin Square

/ Published in: Python

Generates a Latin Square given the top left number and the order of the square

`# take inputs sides = input('Enter a number to make a n*n latin square > ')while True:	if sides.isdigit():		if int(sides) in range(0, 10):			break		else:			sides = input('Enter a number to make a n*n latin square > ')	else:		sides = input('Enter a number to make a n*n latin square > ') topleft = input('Enter a number to be the first in the square > ')while True:	if topleft.isdigit():		if int(topleft) in range(0, 10):			break		else:			topleft = input('Enter a number to be the first in the square > ')	else:		topleft = input('Enter a number to be the first in the square > ') # generates first rowsides = int(sides)topleft = int(topleft) a = list(range(topleft, sides + 1)) + list(range(1, topleft))n = len(a)sqr = [[a[i - j] for i in range(n)] for j in range(n, 0, -1)] for sublist in sqr:    print('')    for num in sublist:        print(str(num), end  = ' ')`