[Tutor] For Loop
Martin A. Brown
martin at linux-ip.net
Fri Oct 30 13:48:17 EDT 2015
Hello Shelby,
> I was wondering if someone can complete a for loop in an array for
> me.
Your question is a bit too terse. You don't give us too much detail
in understanding what you want to do.
But, we are the Tutor list and we are here to help!
Here are a few things which may help you get started....
* A few other programming languages refer to an array as a basic
data type. In Python, it is the 'list', which is the analogous
basic data type (although there is a an 'array' data type). You
should start by learning how to use a Python 'list', though.
* A for loop on a list is very easy. Here's a Python3 code
snippet:
data = list(range(10)) # -- put 10 elements in a list
for item in data:
print(item)
* You may find it helpful to work through some tutorial material.
There are many. We can help you choose one if you tell us what
you are trying to do. I will suggest the main Python tutorial
at the language documentation site as a starting place. Since
you asked about for loops, you probably want to read about
control flow.
https://docs.python.org/3/tutorial/
https://docs.python.org/3/tutorial/controlflow.html
If you have more specific details on what you are trying to
accomplish and/or learn, then send along those questions!
Good luck as you get started,
-Martin
--
Martin A. Brown
http://linux-ip.net/
More information about the Tutor
mailing list