Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
1452e4cd
Commit
1452e4cd
authored
Nov 30, 1998
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change "for" explanation slightly based on comment passed along by
Blake Winton <BlakeW@pcdocs.com>.
parent
e48c5433
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
7 deletions
+10
-7
Doc/tut/tut.tex
Doc/tut/tut.tex
+10
-7
No files found.
Doc/tut/tut.tex
View file @
1452e4cd
...
...
@@ -878,13 +878,16 @@ if', and is useful to avoid excessive indentation. An
\section
{
\keyword
{
for
}
Statements
\label
{
for
}}
The
\keyword
{
for
}
statement in Python differs a bit from what you may be
used to in
\C
{}
or Pascal. Rather than always iterating over an
arithmetic progression of numbers (like in Pascal), or leaving the user
completely free in the iteration test and step (as
\C
{}
), Python's
\keyword
{
for
}
statement iterates over the items of any sequence (e.g., a
list or a string), in the order that they appear in the sequence. For
example (no pun intended):
The
\keyword
{
for
}
\stindex
{
for
}
statement in Python differs a bit from
what you may be used to in
\C
{}
or Pascal. Rather than always
iterating over an arithmetic progression of numbers (like in Pascal),
or giving the user the ability to define both the iteration step and
halting condition (as
\C
{}
), Python's
\keyword
{
for
}
\stindex
{
for
}
statement iterates over the items of any sequence (e.g., a list or a
string), in the order that they appear in the sequence. For example
(no pun intended):
% One suggestion was to give a real C example here, but that may only
% serve to confuse non-C programmers.
\begin{verbatim}
>>> # Measure some strings:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment