Tuple
  • Tuple is immutable, not able to be modified
  • #!/usr/bin/python
    
    a = 1, 2, 3; #or a = (1, 2, 3), create a tuple
    
    #access an element
    print a[0]; #1
    
    #concate two tuple
    b = a+(4, 5, 6); #(1, 2, 3, 4, 5, 6)
    
    #slicing
    print type(b[:2]), b[:2]; #create a tuple (1, 2)
    
    #swaping
    c = 10;
    d = 100;
    d, c = c, d;
    print c, d; #100 10
    		
    Reference
  • Tutorialspoint