Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Created July 17, 2020 04:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IndhumathyChelliah/1d2ca666db53f6d9ae82e395521ecfc3 to your computer and use it in GitHub Desktop.
Save IndhumathyChelliah/1d2ca666db53f6d9ae82e395521ecfc3 to your computer and use it in GitHub Desktop.
t=('red','blue','green',1,2,3)
#starts from first index and ends at second index.(third index not included)
print (t[1:3]) #Output: ('blue', 'green')
#starts from first index till end of tuple
print (t[1:])#Output: ('blue', 'green', 1, 2, 3)
# returns tuple containing all elements.
print (t[:]) #Output: ('red', 'blue', 'green', 1, 2, 3)
#starts from beginning till second index.
print (t[:3]) #Output:('red', 'blue', 'green')
print (t[-3:-1]) #Output:(1, 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment