Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python tuple example

# Creating a Tuple with
# the use of Strings
Tuple = ('Geeks', 'For')
print("
Tuple with the use of String: ")
print(Tuple)
      
# Creating a Tuple with
# the use of list
list1 = [1, 2, 4, 5, 6]
print("
Tuple using List: ")
Tuple = tuple(list1)
  
# Accessing element using indexing
print("First element of tuple")
print(Tuple[0])
  
# Accessing element from last
# negative indexing
print("
Last element of tuple")
print(Tuple[-1])
  
print("
Third last element of tuple")
print(Tuple[-3])
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #python #tuple
ADD COMMENT
Topic
Name
8+1 =