Page 111 - Trackpad_V5_Book 8
P. 111

The syntax of for loop is as follows:
            for <variable> in <sequence>:
                statement(s)

            Program 5: To print all the days of a week.












            You will get the following output:


















            The range function
            We can generate a list of numbers ranging from a starting number up to the number just before
            the ending number.
            Program 6: To print "Range Example" using the range function.















            You will get the following output:























                                                                                   Control Structures in Python  109
   106   107   108   109   110   111   112   113   114   115   116