Python-for Loop and Range () built-in functions

Source: Internet
Author: User

For loop syntax structure columns such as sequences or iterators as their arguments each iteration of one element is the same as a while loop, with support for BREAK,CONTINUE,ELSE statements in general, the number of loops is unknown in the while loop, and the number of cycles is known to use the for
 for inch ' ABCD ' :...      Print ch ... abcd  for inch ' ANCD ' :...      Print Ch,... a n c d

The print statement adds a newline character to each line by default, as long as you add a comma after the print statement, you do not wrap.

The range function for loop is often used with the range function to provide a loop condition with the full syntax of the range function: Range (start,end,step=1)
>>> Range (1,4) [1, 2, 3]>>> range (41, 2, 3]>>> Range ( 1,4,2) [1, 3]
Rage generates a list of print list subscripts and values
alist=[' Tom ', ' Bob ', ' vs ', ' cm ', '
for inch Range (len (alist)): ... . Print " %s:%s " % (I,alist[i]) ... 0:tom1: Bob2: vs3:cm

Python-for Loop and Range () built-in functions

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.