problem:
I have a practice activity with my online class that tells me to manipulate strings in 8 different orientations and put it in a list. 1. left to right, 2. right to left, 3. top to buttom, 4. buttom to top, 5. diagonally buttom left to upper right, 6. diagonally upper right to buttom left, 7. diagonally buttom right to upper left, 8. diagonally upper left to lower right. The code should be compatible with any dimension of the file given. reverse
method can be used.
Any help will be much appreciated. I'm a newbie at these.
text to manipulate (in letters.txt file):
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
expected output:
leftToRight = ['ABCDEF', 'GHIJKL', 'MNOPQR', 'STUVWX', 'YZ']
rightToLeft = ['FEDCBA', 'LKJIHG', 'RQPONM', 'XWVUTS', 'ZY']
topToButtom = ['AGMSY', 'BHNTZ', 'CIOU', 'DJPV', 'EKQW', 'FLRX']
buttomToTop = ['YSMGA', 'ZTNHB', 'UOIC', 'VPJD', 'EKQW', 'FLRX']
bLeftToURight = ['A', 'GB', 'MHC', 'SNID', 'YTOJE', 'ZUPKF', 'VQL', 'WR', 'X']
uRightToBLeft = ['A', 'BG', 'CHM', 'DINS', 'EJOTY', 'FKPUZ', 'LQV', 'RW', 'X']
bRightToULeft = ['Y', 'ZS', 'TM', 'UNG', 'VOHA', 'WPIB', 'XQJC', 'RKD', 'LE', 'F']
uLeftToBRight = ['Y', 'SZ', 'MT', 'GNU', 'AHOV', 'BIPW', 'CJQX', 'DKR', 'EL', 'F']
my code so far for opening the file and trying out left to right:
leftToRight = []
openL = open("letters.txt")
letters = openL.read()
letters = letters.replace(" ","")
for line in letters:
leftToRight.append(line.strip())
print(lefToRight)
prints:
['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']
should print:
['ABCDEF', 'GHIJKL', 'MNOPQR', 'STUVWX', 'YZ']