Created
May 15, 2018 01:00
-
-
Save AhmedZahid098/0fe00d44f50f1a59d0bc13a2d653ec6d to your computer and use it in GitHub Desktop.
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
# Tuples are sequences, like lists, but they are immutable, like strings | |
# Syntactically, they are normally coded in parentheses instead of square brackets, | |
# and they support arbitrarytypes, arbitrary nesting, and the usual sequence operations. | |
# A Tuple and its length is as below | |
T = (1, 'a', 2, 'b', 3, 'c') | |
print (T) | |
print(len(T)) | |
# Indexing | |
print(T[2]) | |
# slicing | |
print(T[3:]) | |
# Concatination didn't happen | |
T = T + () | |
print(T) | |
# Method of Tuple --> tuple.index(index) --> didn't work | |
a = T.index(2) | |
print(a) | |
# Method of Tuple --> tuple.count(index) --> didn't work | |
a = T.count(1) | |
print(a) | |
# Cannot grow and shrink the tuples although it is possible use nesting |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment