Python Text Decrypter

This was a challenge that required I make a script that accepts an unsorted list of words in an [index word] format

The script would then decode the hidden message and present it to the user. The decryption method is as follows: arrange the given list in a triangular structure. Then, take the rightmost side of this triangle and that is you message. Here is a visual aid to represent this method. Each hidden word is colored in orange.

1

23

456

Here is my script that accomplished the task:

def splitNums(word_list):
____split_text = []
____for text in word_list:
________text = text.split(' ') #return 2 elements, our identifier, and the word
________text[0] = int(text[0]) #cast the identifier as an integer to allow proper sort
________split_text.append(text) #add the properly formatted text to our new list
____return split_text
def create_pyramid(nums): #repurposed create pyramid script form earlier
step = 1
subsets = []
while len(nums) != 0:
____if len(nums) >= step:
____subsets.append(nums[0:step])
____nums = nums[step:]
____step += 1
____else:
____return False
return subsets
def decode_pyramid(encoded_pyramid):
____decoded_sentence = ''
____for x in encoded_pyramid: #selects each level of the pyramid
________decoded_sentence = decoded_sentence+(x[len(x)-1][1])+' ' # appends the last element of each list subset to the decoded_pyramid list. x represents the level of the pyramid we are on | the first [len(x)-1] selects the last element in the row, and [1] selects only the second element in said last element. We then add this to the current sentence.
____return decoded_sentence
file = open('test.txt', 'r') #open our txt file with encrypted message
all_lines = file.read().splitlines() #read the file and split into lines then set that values as all_lines, a list of each line without the /n operator
all_lines = splitNums(all_lines)
all_lines.sort() #Puts the list in numerical order since given format has the initial character as number
print(decode_pyramid(create_pyramid(all_lines)))
file.close() #Close the file when done to prevent any memory leaks

Test.txt test2.txt