Guest User

Untitled

a guest
Apr 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. # 04/13/2018 - Okay, so I just had an amazing moment when I discovered a cool trick in python.
  2.  
  3. # There is such a thing in Python called 'List Comprehention', which allows someone the ability
  4. # to loop through a multidimentional array in python
  5.  
  6. # Keep in mind that this demonstration is in Python 3.
  7.  
  8. #So, given a list:
  9.  
  10. x = [[1,2,3],[1,2,3],[1,2,3]]
  11. #You can now loop through this list and print the fist index like so:
  12.  
  13. loop = [iterator[0] for interator in x]
  14. print(loop)
  15.  
  16. # Now, if you run this code, you will print out just the first index in the list
Add Comment
Please, Sign In to add comment