Exercise

The target of this exercise is to create two lists called x_list and y_list, which contain 10 instances of the variables x and y, respectively. You are also required to create a list called big_list, which contains the variables x and y, 10 times each, by concatenating the two lists you have created.

x = object()
y = object()

# TODO: code already changed. this is the answer.
x_list = [x] * 10
y_list = [y] * 10
big_list = x_list + y_list

print("x_list contains %d objects" % len(x_list))
print("y_list contains %d objects" % len(y_list))
print("big_list contains %d objects" % len(big_list))

# testing code
if x_list.count(x) == 10 and y_list.count(y) == 10:
    print("Almost there...")
if big_list.count(x) == 10 and big_list.count(y) == 10:
    print("Great!")

Trinket.io on-line Python compiler

 

Related Videos:

MiltonMarketing.com Related Videos.

Related Posts:

My little pony learning game in VB.NET

Methods of teaching programming

Learn Python Lists

Learn about Python Conditions

Learn RE – Regular Expressions in Python

What is Python?

Learn List Comprehensions in Python Programming

Python String Formatting

Introduction to Python Programming Language

Learn about programming Functions in Python

Learn Partial functions Python programming

Learn Modules and Packages in Python programming

Object-Oriented Programming (OOP)

Learn about Dictionaries datatype for Python

How can Alice help teach OOP (Object Oriented Programming)?

Introduction to JavaScript – Variables: String Interpolation

Introduction to JavaScript

Learn about Numpy Arrays in Python programming

JavaScript Comparison Operators

Introduction to JavaScript – Variables: Review

Learn about programming Loops in Python

Introduction to JavaScript – CONSOLE

Introduction to JavaScript – Variables

Using the Current Year in Your Posts – WordPress

Learn Python Hello World Program

How to make a go-back button with PHP code?

Exception Handling in Python programming

Why do most sites use cookies?

Who is this Android App Development course for?

Hello World Android app built with Android Studio

Learn about Python Generators

Android Studios

Your first Hello World app in C# Sharp

Python Basic String Operations

Python Serialization (JSON)

FAQs