Get positive elements from given list of lists in Python

Pradeep Elance
Updated on 15-Mar-2026 17:49:52

594 Views

Lists can be nested, meaning the elements of a list are themselves lists. In this article we will see how to extract only the positive numbers from a list of lists. The result will be a new list containing nested lists with only positive numbers. Using List Comprehension List comprehension provides a concise way to filter positive elements from nested lists. We use nested list comprehension to iterate through each sublist and filter elements greater than zero ? Example listA = [[-9, -1, 3], [11, -8, -4, 434, 0]] # Given list print("Given List ... Read More

Finding frequency in list of tuples in Python

Pradeep Elance
Updated on 15-Mar-2026 17:49:34

632 Views

When working with lists containing tuples, you may need to find how frequently a specific element appears across all tuples. Python provides several efficient methods to count occurrences of elements within tuple structures. Using count() and map() The map() function extracts elements from each tuple, then count() finds the frequency of a specific element ? # initializing list of tuples fruits_days = [('Apple', 'Mon'), ('Banana', 'Tue'), ('Apple', 'Wed'), ('Orange', 'Thu'), ('Apple', 'Fri')] # Given list print("Given list of tuples:", fruits_days) # Frequency in list of tuples freq_result = list(map(lambda i: i[0], fruits_days)).count('Apple') # ... Read More

Create Horizontal Scrollable Sections in CSS

Jaisshree
Updated on 15-Mar-2026 17:49:32

1K+ Views

A horizontal scrollable section is a popular web design pattern used to showcase content that extends beyond the width of the viewport. This design pattern allows users to scroll horizontally, providing a unique and engaging way to display large images, galleries, timelines, maps, and other content. Syntax .container { overflow-x: auto; white-space: nowrap; } .section { display: inline-block; width: 100vw; vertical-align: top; } Key Properties PropertyValuePurpose overflow-xauto or scrollEnables horizontal scrolling white-spacenowrapPrevents ... Read More

Find sum of frequency of given elements in the list in Python

Pradeep Elance
Updated on 15-Mar-2026 17:49:14

594 Views

When working with lists containing repeated elements, we often need to find the sum of frequencies for specific items. Python provides several approaches to calculate this efficiently ? Using sum() with count() This method uses the built-in count() method to find frequency of each element and sum() to calculate the total ? chk_list = ['Mon', 'Tue'] big_list = ['Mon', 'Tue', 'Wed', 'Mon', 'Mon', 'Tue'] # Apply sum res = sum(big_list.count(elem) for elem in chk_list) # Printing output print("Given list to be analysed:") print(big_list) print("Given list with values to be analysed:") print(chk_list) print("Sum of the ... Read More

Create Horizontal Scroll Snap Using HTML and CSS

Jaisshree
Updated on 15-Mar-2026 17:49:02

958 Views

To create a horizontal scroll snap, we use the CSS scroll-snap-type property to produce the snap effect. The properties scroll-snap-type and scroll-snap-align specify the type of snap behavior and the alignment of the snap points, respectively. Syntax /* Container */ .container { scroll-snap-type: x mandatory; overflow-x: scroll; } /* Items */ .item { scroll-snap-align: start | center | end; } Key Properties PropertyValueDescription scroll-snap-typex mandatoryEnables mandatory horizontal scrolling snap scroll-snap-alignstartAligns snap points to the start of each section overflow-xscrollEnables horizontal ... Read More

Find frequency of given character at every position in list of lists in Python

Pradeep Elance
Updated on 15-Mar-2026 17:48:55

338 Views

Let's consider a scenario where you have a list which is made of lists as its elements. We are interested in finding the frequency of one character at different positions of the inner lists. Below example will clarify the requirement. Consider a list of lists given below: listA = [['a', 'a', 'b'], ['a', 'c', 'b'], ['c', 'a', 'b'], ['c', 'a', 'a']] print("Original list of lists:") print(listA) Original ... Read More

How do I write CSS within HTML?

Ayush Singh
Updated on 15-Mar-2026 17:48:46

274 Views

CSS (Cascading Style Sheets) can be written directly within HTML documents to style and format web pages. There are three primary methods to include CSS within HTML: inline CSS, internal CSS, and a combination of both methods. Syntax /* Inline CSS */ /* Internal CSS */ selector { property: value; } Method 1: Inline CSS Inline CSS uses the style attribute directly within HTML elements. This method has the highest specificity and will override other CSS styles. Example ... Read More

Extract only characters from given string in Python

Pradeep Elance
Updated on 15-Mar-2026 17:48:32

3K+ Views

Sometimes strings contain a mix of letters, numbers, and special characters. When you need to extract only the alphabetic characters from such strings, Python provides several efficient methods. Using isalpha() Method The isalpha() method checks if a character is alphabetic. You can combine it with a loop and join() to extract only letters ? Example text = "Qwer34^&t%y" # Given string print("Given string:", text) # Extract characters using isalpha() result = "" for char in text: if char.isalpha(): result = "".join([result, ... Read More

How do I develop a webpage using HTML and CSS?

Ayush Singh
Updated on 15-Mar-2026 17:48:25

553 Views

Web pages on the internet are built with HTML and styled with CSS. HTML provides the structure and content skeleton, while CSS handles the visual presentation. Learning to develop web pages requires understanding both technologies and how they work together. Syntax /* CSS Syntax */ selector { property: value; } Content HTML Fundamentals HTML (HyperText Markup Language) is the foundation of web development. It uses a hierarchical structure with tags to mark up content: Tags − Enclosed in angle brackets (< >), tags define ... Read More

Extract numbers from list of strings in Python

Pradeep Elance
Updated on 15-Mar-2026 17:48:14

2K+ Views

While using Python for data manipulation, we may come across lists whose elements are a mix of letters and numbers with a fixed pattern. In this article we will see how to separate the numbers from letters which can be used for future calculations. Using split() Method The split() function splits a string by help of a character that is treated as a separator. In the program below the list elements have hyphen as their separator between letters and numbers. We will use that along with list comprehension to extract each number ? days_with_numbers = ['Mon-2', ... Read More

Advertisements