Creating a Python for
often arises the need to go through all the items in a list or perform a transaction through a series of numbers. Python for statement is a powerful and flexible tool that allows you to easily go through a variety of different types of lists and ranges .
To Create a statement with a list Create a Python
list containing the data you want to work: myList = [ 'passion fruit', 'kava kava', 'ACAI', 'grenada']
determine what operations you want to do what you go through each of elements in the list. For this example, to take each item on the list just declare and print the word “fruit” from the list element .
Create a statement of use from the list: for MyItem in myList: print 1 ‘Fruit’ myitemThis printed the following: Fruit: passion fruitFruit: kava kavaFruit: acaiFruit: grenada
To Create a statement with a range
determine a series numbers you want to loop over. For this example, you select the range starting at 5 and ends at 10 .
to determine the events that occur while going through the elements of the range. For this example, you add 10 to each element in the range of print and out .
Create a statement of use of the range () method. Will save each item in the range of your meter in the variable k. The range method of generating a list from the first element and ending just before the last element. The range extends to the second parameter. However, it includes the second number. Thus, in this example, call the normal (5.11): for k in range (5,10): print k 10This will produce the result: 151617181920
Featured Links:
Proven Money Maker At $9,547 A Day.
Burn The Fat - Top Selling Fat Loss Ebook Since 2003.
Have You Ever Stayed Awake at Night Stressing About Whether or Not Your Marriage Will Last ... And What You Can Possibly Do to Save It?
Scan your computer for hidden AdWare and Spyware, Remove them permanently.
Join the Internet revolution and start downloading free movies and more!
Internet Marketer Gets $87 Million in Google Pay-Per-Click Ads FREE! ... And Makes Over $314 Million as a Result! ...And Now He's Going to Give You This Same Secret for Next to Nothing!








Leave a comment
You must be logged in to post a comment.