In this chapter, we'll delve into the story of Abram's call and discover how to work with lists in Python programming. Abram's journey of faith will teach us the significance of trust and obedience, as well as the value of following God's guidance. We will relate these lessons to the use of lists in programming, which allow us to store and organize various pieces of information in an efficient and accessible manner.

Read the Bible

Genesis 12:1-9

Reflection

  1. How does Abram's trust in God when he follows His call show us the importance of faith? What can we learn from Abram's willingness to go where God leads him in our own lives?
  2. Obeying God wasn't a piece of cake for Abram; he had a bunch of tasks to finish on his adventure, like taking care of people and stuff. Can you think of a way to remember lots of things in a certain order, just like Abram had to manage different parts of his journey?

Learn about programming

Lists

On Abram's adventure, he needed to keep track of many things, like tasks and belongings. In the programming world, we have something called lists that can help us keep everything neat and tidy. A list is like a treasure chest in Python that can hold a bunch of items. We create lists with square brackets [ ] and can store all kinds of things in them, like numbers, words, and even other lists.

For example, let's pretend we're helping Abram stay organized on his journey by remembering the places he's been. We can make a list called visited_places to store the names of the spots he's visited in the order he went to them:

visited_places = ['Haran', 'Canaan', 'Egypt', 'Bethel', 'Hebron']

Now, we have a list called visited_places that holds five different locations in the order Abram visited them. If we want to access an item in the list, we can use its index in the list. In Python, indices start from 0. So, to access the first place in the list, we can do the following:

visited_places = ['Haran', 'Canaan', 'Egypt', 'Bethel', 'Hebron']
first_place  = visited_places[0]
print(first_place) # Output: Haran

Similarly, if we want to access the third place in the list, we can do the following:

visited_places = ['Haran', 'Canaan', 'Egypt', 'Bethel', 'Hebron']
third_place = visited_places[2]
print(third_place) # Output: Egypt

We can also access an item from the end of the list using negative indices. Suppose Abram wants to find out the most recent place he visited. We can use negative indices to access the list items from the end. To access the last item in the list, we can use an index of -1. Here's an example:

visited_places = ['Haran', 'Canaan', 'Egypt', 'Bethel', 'Hebron']
most_recent_place = visited_places[-1]
print(most_recent_place ) # Output: Hebron

By using indices, we can access and work with specific items in a list, making it a powerful tool to organize and manage related information. Now that we know how to access specific items in a list using indices, let's learn how to modify the list by adding or removing items, using methods like append(), insert(), and remove().

Suppose Abram visits a new place called Mamre. We can add this place to the end of our visited_places list using the append() method:

visited_places = ['Haran', 'Canaan', 'Egypt', 'Bethel', 'Hebron']
visited_places.append('Mamre')
print(visited_places)