Coding with AI

Code Faster. Think Smarter. Ship Better—with AI.

Stop fighting boilerplate and busywork. Coding with AI shows professional Python developers how to use AI tools to accelerate design, coding, testing, debugging, and documentation—without sacrificing quality or control. Learn proven prompts, real workflows, and practical techniques you’ll use on the job every day.

Explore the book ->


Understanding and Using Lists in Python

A list is an ordered collection of items, which can be of any type. It’s one of the most powerful data types in Python. This article will help you understand how lists are used and how to print them e …

Updated November 30, 2023

A list is an ordered collection of items, which can be of any type. It’s one of the most powerful data types in Python. This article will help you understand how lists are used and how to print them effectively.

Lists in Python A list in python is a special kind of iterable which means it has an order and can be indexed, sliced or looped through. They are mutable i.e., they can be changed after creation.

Lists are created using square brackets [] and items are separated by commas. Here’s how you could create a list in Python:

fruits = ["apple", "banana", "cherry"]
print(fruits)

Printing Lists The print statement can be used to display the entire list at once or you can iterate through each item in the list.

  1. Print all items:
fruits = ["apple", "banana", "cherry"]
print(fruits)
  1. Print each item one by one:
fruits = ["apple", "banana", "cherry"]
for fruit in fruits:
    print(fruit)

In both cases, the output would be:

['apple', 'banana', 'cherry']
apple
banana
cherry

The square brackets are only necessary if you want to display all items at once. If you use print without brackets, it will print each item on a new line as per its order in the list.

Coding with AI

AI Is Changing Software Development. This Is How Pros Use It.

Written for working developers, Coding with AI goes beyond hype to show how AI fits into real production workflows. Learn how to integrate AI into Python projects, avoid hallucinations, refactor safely, generate tests and docs, and reclaim hours of development time—using techniques tested in real-world projects.

Explore the book ->