> For the complete documentation index, see [llms.txt](https://igb.mit.edu/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://igb.mit.edu/mini-courses/python/introduction-to-python-for-biologists/loops/while-loops.md). Agents can also search and read this documentation through its [MCP server](https://igb.mit.edu/~gitbook/mcp).

# While Loops

### While Loops

```
In [1]: i=1

In [2]: while (i<5):
   ...:     print(i)
   ...:     i=i+1
   ...:     
1
2
3
4

In [3]: i=0

In [4]: instructors=["Duan","Charlie","Stuart","Allen"]

In [5]: while (i<4):
   ....:     print("Hello,", instructors[i])
   ....:     i=i+1
   ....:     
Hello, Duan
Hello, Charlie
Hello, Stuart
Hello, Allen
```
