← Back to list

My Python Learning Journey — Week 2: Mastering Lists, Tuples, Dictionaries, Sets, Strings, and…

After completing the fundamentals of Python in Week 1, I continued my learning journey by exploring Python’s built-in data structures and…

Angayarkanni Balasubramanian · 2026-06-16 09:36 · 0 claps · 3.2 min read
#python #programming #python-for-beginners #software-development #learning-journey
Open on Medium ↗
Wiki topics: EDU · Education & Learning 💻 · Programming

My Python Learning Journey — Week 2: Mastering Lists, Tuples, Dictionaries, Sets, Strings, and Exception Handling

After completing the fundamentals of Python in Week 1, I continued my learning journey by exploring Python’s built-in data structures and error-handling mechanisms.

As someone coming from an Angular and TypeScript background, I quickly realized that these concepts form the backbone of real-world Python applications. Whether you’re building APIs, automation scripts, data processing tools, or AI applications, you’ll use these concepts every day.

In this article, I’ll share what I learned during Week 2 and how these concepts help developers write cleaner and more efficient Python code.

Why Data Structures Matter

Imagine building an application without a way to store multiple values, organize information, or handle unexpected errors.

Data structures help us manage data efficiently, while exception handling ensures our applications don’t crash when something goes wrong.

Let’s explore the concepts I learned this week.

Lists: The Most Common Collection

Lists are used to store multiple values in a single variable.

fruits = ["Apple", "Orange", "Mango"]
print(fruits)

Output:

['Apple', 'Orange', 'Mango']

Accessing values:

print(fruits[0])

Output:

Apple

Looping through a list:

for fruit in fruits:
    print(fruit)

Lists are similar to arrays in JavaScript and TypeScript.

Useful List Methods

Adding items:

fruits.append("Banana")

Removing items:

fruits.remove("Orange")

Sorting:

fruits.sort()

Lists are extremely flexible and are probably the most frequently used collection type in Python.

Tuples: Immutable Collections

Tuples are similar to lists but cannot be modified after creation.

colors = ("Red", "Blue", "Green")
print(colors)

Accessing values:

print(colors[1])

Output:

Blue

Why Use Tuples?

Tuples are useful when:

  • Data should not change.
  • You want better performance.
  • You want to protect values from accidental modification.

For example:

months = (
    "January",
    "February",
    "March"
)

The months of a year don’t change, making a tuple a good choice.

Dictionaries: Python’s Powerful Key-Value Store

Dictionaries are one of my favorite Python features because they closely resemble JSON objects.

user = {
    "name": "John",
    "age": 25,
    "city": "Chennai"
}

Accessing values:

print(user["name"])

Output:

John

Using .get():

print(user.get("age"))

Looping through a dictionary:

for key, value in user.items():
    print(key, value)

Output:

name John
age 25
city Chennai

Dictionaries are heavily used in:

  • APIs
  • JSON Processing
  • Database Records
  • Configuration Files

Understanding dictionaries is essential for every Python developer.

Sets: Storing Unique Values

Sets automatically remove duplicate values.

numbers = {1, 2, 3, 4, 4, 4}
print(numbers)

Output:

{1, 2, 3, 4}

Notice how duplicates were removed automatically.

Set Operations

Union:

set1 = {1, 2, 3}
set2 = {3, 4, 5}
print(set1.union(set2))

Output:

{1, 2, 3, 4, 5}

Intersection:

print(set1.intersection(set2))

Output:

{3}

Sets are useful for:

  • Removing duplicates
  • Comparing datasets
  • Membership testing

String Functions

Strings are everywhere in programming.

Python provides many built-in functions to manipulate strings.

name = "python"

Convert to uppercase:

print(name.upper())

Output:

PYTHON

Capitalize:

print(name.capitalize())

Output:

Python

Replace text:

print(name.replace("python", "Python"))

Output:

Python

These methods make text processing simple and efficient.

Exception Handling: Writing Safer Programs

No matter how carefully we write code, errors can still happen.

Without exception handling:

result = 10 / 0

This causes:

ZeroDivisionError

Using exception handling:

try:
    result = 10 / 0
except Exception as e:
    print(e)

Output:

division by zero

Instead of crashing, the program continues running gracefully.

Why Exception Handling Is Important

Exception handling is widely used in:

  • API Development
  • Database Operations
  • File Handling
  • User Input Validation

For example:

try:
    age = int(input("Enter Age: "))
except ValueError:
    print("Please enter a valid number")

This improves the user experience and makes applications more reliable.

Comparing Python Collections

CollectionOrderedMutableDuplicates AllowedListYesYesYesTupleYesNoYesDictionaryYesYesKeys NoSetNoYesNo

Understanding when to use each collection is an important step toward becoming an efficient Python developer.

Key Takeaways from Week 2

This week helped me understand how Python manages and organizes data.

I learned:

  • Lists for storing multiple values
  • Tuples for immutable collections
  • Dictionaries for key-value data
  • Sets for unique values
  • String functions for text manipulation
  • Exception handling for safer applications

These concepts may seem simple individually, but together they form the foundation of real-world Python development.

What’s Next?

In Week 3, I plan to learn:

  • Classes
  • Objects+
  • Constructors
  • Inheritance
  • Polymorphism
  • Encapsulation

These Object-Oriented Programming concepts will help me build larger and more maintainable applications.

Final Thoughts

Week 2 was where Python started feeling more practical and powerful.

Coming from TypeScript, dictionaries felt familiar because they resemble JSON objects, while lists and sets provided flexible ways to organize data.

The biggest lesson this week was understanding that writing code isn’t just about making it work — it’s also about making it reliable. Exception handling showed me how Python applications can gracefully recover from unexpected situations.

With two weeks completed, I feel much more comfortable with Python fundamentals and excited to continue exploring the language.

Happy Coding! 🚀🐍


메타데이터
post_id
57dae9cef412
slug
my-python-learning-journey-week-2-mastering-lists-tuples-dictionaries-sets-strings-and-57dae9cef412
url
https://medium.com/@angayarkannibalasubramaniand/my-python-learning-journey-week-2-mastering-lists-tuples-dictionaries-sets-strings-and-57dae9cef412
canonical_url
https://medium.com/@angayarkannibalasubramaniand/my-python-learning-journey-week-2-mastering-lists-tuples-dictionaries-sets-strings-and-57dae9cef412
author_url
https://medium.com/@angayarkannibalasubramaniand
status
ok
fetched_at
2026-06-29 22:44:20