Pacific-Design.com

    
Home Index

1. Python

2. 05 Tupple

Python / 05 Tupple /

Tupple

#!/usr/bin/python
import random

#----------------------------------------------------------------------#
class MyTupple():

    def myTupple(self):

        tupple = ("kevin", "thomas", "duraj")
        print "All =", tupple  
        print "First two", tupple[:2] 

        if "duraj" in tupple: # search "duraj" in tupple
            print "duraj is in tupple "

        print random.choice(tupple) # print random element

#----------------------------------------------------------------------#
if __name__ == "__main__":
    
    ds = MyTupple()
    ds.myTupple()

All = ('kevin', 'thomas', 'duraj') First two ('kevin', 'thomas') duraj is in tupple kevin