Created
December 5, 2019 18:23
-
-
Save m-root/181fa509dbc9f9884e283b0f04cc4cdd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d = [ | |
[9, 4, 0, 0], | |
[0, 6, 0, 0], | |
[0, 0, 3, 0], | |
[0, 0, 0, 4] | |
] # List matrix | |
f = 0 # initilizing for the matrix columns | |
g = 3 # The starting point | |
h = [] # Final Sentence List | |
for e in d: # Here is where I am splitting the list inside the matrix | |
while f < len(d): # Looping through the list itself | |
if g < len(d[f]): # We are looping through each list | |
if d[f][g] > 0: # We are looking for values that are greater than 1 here | |
print(d[f][g]) #Just for you to see if it is working | |
h.append(d[f][g]) #Appening new value to the list | |
elif d[f][g] <= 0: #it is to handle the starting point logic | |
while d[f][g] <= 0: # Will check the value | |
fl = f + 1 # Will initilize the skipping point in the loop | |
if d[fl][g] > 0: # Will do the skipping till it gets to the place where we can get a value greater than 0 | |
break #Breaks if the value is found | |
f = fl #Reassigns the new value of f | |
print(d[f + 1][g]) # Just for you to see if it is working | |
h.append(d[f + 1][g]) # Appening new value to the list | |
g = g + 1 #Counter for g | |
f = f + 1 #Counter for f | |
print(h) #Prints the final list of it all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment