Page 76 - Code Craft Computer-8
P. 76

Syntax:

                 Value in [sequence]
            For example, if you want to check whether the number 10 is present in a given sequence of
            numbers, [1,2,3,10], execute the following code:

            Program 3:












            Output:















            Program 4:













            Output:




















            Using the range() Function
            The range() function is an in-built function of Python. This function generates a list which is a
            sequence type. A sequence is a succession of values bound together by a single name. The range()
            function is used in the ‘for’ loop to iterate over the numbers.




                                                                 76
   71   72   73   74   75   76   77   78   79   80   81