Fundamentals 3 min read

How to Copy Lists and Generate a 9×9 Multiplication Table in Python

This article demonstrates two basic Python examples: copying a list using slicing and printing the full 9×9 multiplication table with nested loops, including the complete source code and expected output for each case.

Python Programming Learning Circle
Python Programming Learning Circle
Python Programming Learning Circle
How to Copy Lists and Generate a 9×9 Multiplication Table in Python

Example 1

Task: Copy the data from one list to another.

Analysis: Use list slicing (list[:]).

<code>#!/usr/bin/python
# -*- coding: UTF-8 -*-

a = [1, 2, 3]
b = a[:]
print(b)
</code>

Output:

<code>[1, 2, 3]
</code>

Example 2

Task: Print the 9×9 multiplication table.

Analysis: Use two nested loops, with i controlling rows and j controlling columns.

<code>#!/usr/bin/python
# -*- coding: UTF-8 -*-

for i in range(1, 10):
    for j in range(1, 10):
        result = i * j
        print('%d * %d = % -3d' % (i, j, result))
    print('')
</code>

Sample output (partial):

<code>1 * 1 =   1
1 * 2 =   2
1 * 3 =   3
1 * 4 =   4
1 * 5 =   5
1 * 6 =   6
1 * 7 =   7
1 * 8 =   8
1 * 9 =   9

2 * 1 =   2
2 * 2 =   4
2 * 3 =   6
2 * 4 =   8
2 * 5 =  10
2 * 6 =  12
2 * 7 =  14
2 * 8 =  16
2 * 9 =  18

... (continues for rows 3 through 9) ...
</code>
pythonslicingNested Loopsbasic programminglist copyingmultiplication table
Python Programming Learning Circle
Written by

Python Programming Learning Circle

A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.