Showing posts with label hobby. Show all posts
Showing posts with label hobby. Show all posts

November 24, 2016

Intro to Python: Containers, Functions, and Loops (Part 2 /2)

This is the second post in a series. If you're just getting started, see Part 1.

In the previous post, you got python installed, and ran a simple program. In this section we will use some language features to store data, and re-use code. These are important concepts for all programming languages.


Before we get started, let me warn you to pay attention to your indentation / white space here. Python doesn't care if you use tabs or spaces for white space, but does require that indented blocks are consistent. 

Lists


The first container we will look at is a list. A list is rather unsurprisingly just a series of items in a single object. To create a list, you just assign values inside square brackets separated by commas. After it is created you can add values using your_list_name.append(value).