Articles on Trending Technologies

Technical articles with clear explanations and examples

Get first element of each sublist in Python

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 5K+ Views

A list in Python can also contain lists inside it as elements. These nested lists are called sublists. In this article we will solve the challenge of retrieving only the first element of each sublist in a given list. Using for Loop It is a very simple approach in which we loop through the sublists fetching the item at index 0 in them. A for loop is used for this purpose as shown below ? Example nested_list = [['Mon', 1], ['Tue', 'Wed', "Fri"], [12, 3, 7]] print("Given List:", nested_list) print("First Items from sublists:") for item ...

Read More

How to Separate Header from Body in HTML?

Souvik Chakraborty
Souvik Chakraborty
Updated on 15-Mar-2026 660 Views

To separate header from body in HTML, you can create visual and structural distinction between the header section and the main content. The header typically contains navigation, titles, and introductory elements, while the body holds the primary content of the webpage. In this article, we will explore different approaches to effectively separate the header from the body content using HTML structure and CSS styling. Approaches to Separate Header from Body Using Semantic HTML Tags Using CSS Styling Using Multiple Headers Method 1: Using Semantic HTML Tags HTML5 provides semantic tags that help create ...

Read More

Count unique sublists within list in Python

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 619 Views

A Python list can contain sublists, which are lists nested within a larger list. In this article we will explore how to count the number of unique sublists within a given list using two different approaches. Using Counter Counter is a subclass of Dictionary used to keep track of elements and their count. It stores elements as dictionary keys and their count as dictionary values. To count sublists, we convert each sublist to a string representation ? Example from collections import Counter # Given List with sublists days_list = [['Mon'], ['Tue', 'Wed'], ['Tue', 'Wed']] ...

Read More

Check if list contains all unique elements in Python

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 10K+ Views

A list in Python can contain elements all of which may or may not be unique. But for scenarios when we need unique elements like marking attendance for different roll numbers of a class, we need to check if all elements are unique. Below are the approaches we can use. Using set() Method A Python set is a collection which is unordered, unindexed and contains only unique elements. We can compare the length of the set created from the list with the length of the list itself. They will be equal only if there are unique elements in ...

Read More

How to Decompile an HTML File?

Souvik Chakraborty
Souvik Chakraborty
Updated on 15-Mar-2026 398 Views

Decompiling an HTML file refers to examining and understanding the source code that creates a webpage. Unlike compiled programming languages, HTML is already in human-readable format, making it easily accessible for analysis and learning purposes. In this article, we will explore various methods to examine and work with HTML file content. Method 1: Viewing Source Code in Browser The most straightforward approach to examine HTML code is through your web browser's built-in source viewing feature. Steps Navigate to the webpage you want to examine Right-click anywhere on the page and select "View Page Source" ...

Read More

Assign ids to each unique value in a Python list

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 1K+ Views

When working with Python lists, you may need to assign unique IDs to each distinct value while ensuring that duplicate values receive the same ID. This is useful for data analysis, categorization, and indexing operations. Using enumerate() and OrderedDict.fromkeys() The enumerate() function creates a counter for each element, while OrderedDict.fromkeys() preserves the first occurrence order and eliminates duplicates ? from collections import OrderedDict values = ['Mon', 'Tue', 'Wed', 'Mon', 5, 3, 3] print("The given list:", values) # Assigning ids to values list_ids = [{v: k for k, v in enumerate( ...

Read More

How to Compare Two HTML Elements?

Souvik Chakraborty
Souvik Chakraborty
Updated on 15-Mar-2026 426 Views

Comparing HTML elements in JavaScript is a common requirement when building dynamic web applications. You might need to check if two elements have the same tag name, classes, content, or other properties. This article explores two effective methods for comparing HTML elements using JavaScript. Method 1: Manual Element Comparison Manual comparison gives you complete control over which properties to compare. This method directly checks specific attributes like tag name, class name, and content − Manual HTML Elements Comparison ...

Read More

Python to Find number of lists in a tuple

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 417 Views

A Python tuple is ordered and unchangeable. It can contain lists as its elements. Given a tuple made up of lists, let's find out how many lists are present in the tuple using different approaches. Using len() Function The simplest approach is to use the built-in len() function, which returns the count of elements (lists) in the tuple ? tupA = (['a', 'b', 'x'], [21, 19]) tupB = (['n', 'm'], ['z', 'y', 'x'], [3, 7, 89]) print("The number of lists in tupA:", len(tupA)) print("The number of lists in tupB:", len(tupB)) The output of ...

Read More

How do I CSS transition a modal dialog element when it opens?

Souvik Chakraborty
Souvik Chakraborty
Updated on 15-Mar-2026 568 Views

CSS transitions can significantly improve the user experience of modal dialogs by providing smooth animations when they open and close. Using the modern HTML element combined with CSS transitions creates professional-looking modals that feel responsive and polished. Syntax dialog { transition: property duration timing-function delay; } Basic Modal Structure First, create the HTML structure with a button to trigger the modal and the dialog element itself − button { padding: 10px ...

Read More

Find missing numbers in a sorted list range in Python

Pradeep Elance
Pradeep Elance
Updated on 15-Mar-2026 1K+ Views

Given a sorted list of numbers, we want to find out which numbers are missing from the continuous range. Python provides several approaches to identify these gaps in the sequence. Using range() with List Comprehension We can create a complete range from the first to last element and check which numbers are not in the original list ? numbers = [1, 5, 6, 7, 11, 14] # Original list print("Given list:", numbers) # Find missing numbers using range missing = [x for x in range(numbers[0], numbers[-1] + 1) ...

Read More
Showing 19331–19340 of 61,297 articles
Advertisements