Search code examples
pythonlistalphabet

alphabet tableau in python


alphabet = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
matrix = []

for i in range(26):
    change = alphabet[0]
    del alphabet[0]
    alphabet.append(change)
    print(alphabet)
    matrix.append(alphabet)

print("----------")
for i in matrix: print(i)

This supposed to create a 2x2 list that is the alphabet and then the first letter is moved to the end. But ends up being the alphabet 26 times. Please help!


Solution

  • you can use:

    matrix = [alphabet , alphabet[1:] + alphabet[:1]]