Created
September 9, 2017 00:48
-
-
Save garybradski/539209d0332ecff747891e0677736419 to your computer and use it in GitHub Desktop.
python_indexing_slices.py
This file contains 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
my_tuple = ('p','r','o','g','r','a','m','i','z') | |
print("og forward:") | |
print("og: ",my_tuple[2:4]) | |
print("og: ",my_tuple[-7:4]) | |
print("og: ",my_tuple[-7:-5]) | |
print("og: ",my_tuple[2:-5]) | |
print("og backwards (go):") | |
print("go: ",my_tuple[3:1:-1]) | |
print("go: ",my_tuple[-6:1:-1]) | |
print("go: ",my_tuple[-6:-8:-1]) | |
print("go: ",my_tuple[3:-8:-1]) | |
print("orm foward:") | |
print("orm: ",my_tuple[2:7:2]) | |
print("orm: ",my_tuple[-7:7:2]) | |
print("orm: ",my_tuple[-7:-2:2]) | |
print("orm: ",my_tuple[2:-2:2]) | |
print("orm back (mro):") | |
print("mro: ",my_tuple[6:1:-2]) | |
print("mro: ",my_tuple[6:-8:-2]) | |
print("mro: ",my_tuple[-3:1:-2]) | |
print("mro: ",my_tuple[-3:-8:-2]) | |
print("===================") |
Author
garybradski
commented
Mar 6, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment