Extending sequences with ellipsis in Python
Python ellipsis (...) Data Type: Exercise-8 with Solution
Write a Python program that uses Ellipsis to extend a sequence with another sequence.
Sample Solution:
Code:
# Define three sequences
sequence1 = [1, 2, 3]
sequence2 = [4, 5, 6]
sequence3 = [7, 8, 9]
# Extend sequence1, sequence2 and sequence3 using ellipsis
extended_sequence = sequence1 + [...] + sequence2 + [...] + sequence3
# Print the extended sequence
print(extended_sequence)
Output:
[1, 2, 3, Ellipsis, 4, 5, 6, Ellipsis, 7, 8, 9]
In the exercise above, we have three sequences, sequence1, sequence2 and sequence3. We use 'ellipsis (...)' between them to represent an extension operation. The result, extended_sequence, will contain the elements from sequence1, sequence2 and sequence3 concatenated together.
Flowchart:

Previous: Generating sequences with ellipsis in Python.
Next: Creating Python classes with dynamic attributes.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
Python: Tips of the Day
Summing a sequence of numbers (calculating the sum of zero to ten with skips):
>>> l = range(0,10,2) >>> sum(l) 20
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook