Articles on Trending Technologies

Technical articles with clear explanations and examples

Count the sublists containing given element in a list in Python

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

When working with lists in Python, you often need to count how many times a specific element appears. This article demonstrates three different approaches to count occurrences of a given element in a list. Using range() and len() This method uses a loop with range() and len() to iterate through the list indices. A counter variable tracks how many times the element is found ? days = ['Mon', 'Wed', 'Mon', 'Tue', 'Thu'] target = 'Mon' print("Given list:", days) print("Element to check:", target) count = 0 for i in range(len(days)): if ...

Read More

Display div element on hovering over tag using CSS

Yaswanth Varma
Yaswanth Varma
Updated on 15-Mar-2026 601 Views

CSS can be used to make HTML hidden components visible when hovered over. Using the adjacent sibling selector (+), we can display any HTML element when the user hovers over an tag. This selector targets an element that immediately follows another element in the DOM. Syntax a:hover + element { display: block; } How It Works The technique uses these key components − Hidden element: Initially set to display: none Adjacent sibling selector (+): Targets the element immediately after the anchor :hover pseudo-class: Triggers when mouse hovers ...

Read More

Count the Number of matching characters in a pair of string in Python

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

We are given two strings and need to find the count of characters in the first string that are also present in the second string. Python provides several approaches to solve this problem efficiently. Using Set Intersection The set function gives us unique values of all elements in a string. We use the & operator to find common elements between the two strings ? Example strA = 'Tutorials Point' uniq_strA = set(strA) print("Given String:", strA) strB = 'aeio' uniq_strB = set(strB) print("Search character strings:", strB) common_chars = uniq_strA & uniq_strB print("Count of matching ...

Read More

How set the shadow color of div using CSS?

Yaswanth Varma
Yaswanth Varma
Updated on 15-Mar-2026 317 Views

The CSS box-shadow property allows you to add shadow effects to any HTML element, including elements. This property creates a visual depth effect by adding shadows with customizable colors, positions, and blur effects. Syntax selector { box-shadow: h-offset v-offset blur spread color; } Property Values ValueDescription h-offsetHorizontal shadow position (positive = right, negative = left) v-offsetVertical shadow position (positive = down, negative = up) blurOptional. Blur radius − higher values create more blur spreadOptional. Spread radius − positive values expand, negative values shrink colorShadow color (hex, rgb, rgba, ...

Read More

Count of elements matching particular condition in Python

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

In this article, we will see how to count elements in a Python list that match a particular condition. We'll explore different approaches to filter and count elements based on specific criteria. Using Generator Expression with sum() This approach uses a generator expression with an if condition inside the sum() function. The expression generates 1 for each element that matches the condition ? Example days = ['Mon', 'Wed', 'Mon', 'Tue', 'Thu'] # Given list print("Given list:") print(days) # Count elements that are 'Mon' or 'Wed' count = sum(1 for day in days if ...

Read More

Apply Glowing Effect to the Image using HTML and CSS

Yaswanth Varma
Yaswanth Varma
Updated on 15-Mar-2026 1K+ Views

You have probably seen several special effects while browsing the majority of websites, which may be viewed when your cursor is over various images. We are going to process same in this article. Such images could serve as cards for our website. The task we are going to perform in this article is to apply a glowing effect to images using HTML and CSS. This effect can be accomplished by using the box-shadow property. Let's dive into the article to learn more about applying the glowing effect. Syntax selector { box-shadow: none ...

Read More

Count occurrences of an element in a list in Python

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

In this article we are given a list and a string. We are required to find how many times the given string is present as an element in the list. Python provides several methods to count occurrences, each with different advantages. Using count() Method The count() method is the most straightforward approach. It takes the element as a parameter and returns the number of times it appears in the list ? days = ['Mon', 'Wed', 'Mon', 'Tue', 'Thu'] element = 'Mon' # Given list and element print("Given list:", days) print("Given element:", element) count = ...

Read More

Count occurrences of a character in string in Python

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

We are given a string and a character, and we want to find out how many times the given character is repeated in the string. Python provides several approaches to count character occurrences. Using count() Method The simplest approach is using Python's built-in count() method ? text = "How do you do" char = 'o' print("Given String:", text) print("Given Character:", char) print("Number of occurrences:", text.count(char)) Given String: How do you do Given Character: o Number of occurrences: 4 Using range() and len() We can design a for loop to ...

Read More

How to Reduce Space Between Elements on a Row in CSS Bootstrap?

Eesha Gandhi
Eesha Gandhi
Updated on 15-Mar-2026 1K+ Views

Bootstrap's grid system creates automatic spacing (called "gutters") between columns using padding and margins. Sometimes you need to reduce or remove this space to create tighter layouts. Here are several methods to control spacing between elements in Bootstrap rows. Method 1: Using no-gutters Class The simplest method is to add the no-gutters class to your row. This removes all gutters between columns − Bootstrap No Gutters Example Regular Row (with gutters) ...

Read More

Count number of items in a dictionary value that is a list in Python

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

Sometimes we have a dictionary where some values are lists and we need to count the total number of items across all these list values. Python provides several approaches to achieve this using isinstance() to check if a value is a list. Using isinstance() with Dictionary Keys We can iterate through dictionary keys and use isinstance() to identify list values ? # defining the dictionary data_dict = {'Days': ["Mon", "Tue", "Wed", "Thu"], 'time': "2 pm", 'Subjects':["Phy", "Chem", "Maths", "Bio"] } print("Given dictionary:", data_dict) ...

Read More
Showing 19481–19490 of 61,297 articles
Advertisements