M
Would love some feedback to see if this could be coded differently! I did the original one then had ChatGPT clean it up. I’m not experienced enough to know if it’s good coding. Thanks in advance for the help!
Code starts here
import string
Generate the matrix
matrix = [list(string.ascii_lowercase[i:i + 4]) for i in range(0, 26, 4)] matrix[-1].append(‘!’) # Add ‘!’ to the last row
Define indices
indices = [ (0, 3), (3, 2), (3, 1), (0, 0), (2, 3), (0, 3), None, (4, 3), (4, 1), (5, 0), (3, 0), (3, 3), None, (2, 0), (4, 2), None, (0, 1), (0, 0), (0, 2), (2, 2), (6, 2) ]
Extract result
result = “”.join( ” ” if i is None else matrix[i[0]][i[1]] for i in indices ).upper()
Print the result
print(result)
submitted by /u/WonderfulFlan2827
[link] [comments]
r/learnpython M Would love some feedback to see if this could be coded differently! I did the original one then had ChatGPT clean it up. I’m not experienced enough to know if it’s good coding. Thanks in advance for the help! Code starts here import string Generate the matrix matrix = [list(string.ascii_lowercase[i:i + 4]) for i in range(0, 26, 4)] matrix[-1].append(‘!’) # Add ‘!’ to the last row Define indices indices = [ (0, 3), (3, 2), (3, 1), (0, 0), (2, 3), (0, 3), None, (4, 3), (4, 1), (5, 0), (3, 0), (3, 3), None, (2, 0), (4, 2), None, (0, 1), (0, 0), (0, 2), (2, 2), (6, 2) ] Extract result result = “”.join( ” ” if i is None else matrix[i[0]][i[1]] for i in indices ).upper() Print the result print(result) submitted by /u/WonderfulFlan2827 [link] [comments]
M
Would love some feedback to see if this could be coded differently! I did the original one then had ChatGPT clean it up. I’m not experienced enough to know if it’s good coding. Thanks in advance for the help!
Code starts here
import string
Generate the matrix
matrix = [list(string.ascii_lowercase[i:i + 4]) for i in range(0, 26, 4)] matrix[-1].append(‘!’) # Add ‘!’ to the last row
Define indices
indices = [ (0, 3), (3, 2), (3, 1), (0, 0), (2, 3), (0, 3), None, (4, 3), (4, 1), (5, 0), (3, 0), (3, 3), None, (2, 0), (4, 2), None, (0, 1), (0, 0), (0, 2), (2, 2), (6, 2) ]
Extract result
result = “”.join( ” ” if i is None else matrix[i[0]][i[1]] for i in indices ).upper()
Print the result
print(result)
submitted by /u/WonderfulFlan2827
[link] [comments]