Articles on Trending Technologies

Technical articles with clear explanations and examples

How to set the order of flexible items using CSS?

Abhishek
Abhishek
Updated on 15-Mar-2026 383 Views

The CSS order property allows you to change the visual order of flex items without altering their position in the HTML source. This property only works on elements that are children of a flex container (an element with display: flex or display: inline-flex). NOTE − The order property only works with flex items inside a flex container. Syntax selector { order: integer; } Possible Values ValueDescription integerAny integer value (positive, negative, or zero). Default is 0. Items are arranged in ascending order of their order values. ...

Read More

Find top K frequent elements from a list of tuples in Python

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

We have a list of tuples and need to find the top K elements with highest values. For example, if K is 3, we need to find the three tuples with the largest second values. Using defaultdict and sorted This approach uses defaultdict to group elements and then sorts them by value to get the top K elements. Example import collections from operator import itemgetter from itertools import chain # Input list initialization listA = [[('Mon', 126)], [('Tue', 768)], [('Wed', 512)], [('Thu', 13)], [('Fri', 341)]] # Set K K = 3 # ...

Read More

How to set the inset shadow using CSS?

Abhishek
Abhishek
Updated on 15-Mar-2026 529 Views

The CSS box-shadow property creates shadows around elements, and by default applies shadows outside the element. However, by adding the inset keyword, you can create shadows that appear inside the element, giving it a recessed or indented appearance. Syntax selector { box-shadow: inset x-offset y-offset blur spread color; } Parameters ParameterDescription insetMakes the shadow appear inside the element x-offsetHorizontal shadow offset (required) y-offsetVertical shadow offset (required) blurBlur radius (optional, default is 0) spreadSpread distance (optional, default is 0) colorShadow color (optional, default is current text color) Example ...

Read More

Find the tuples containing the given element from a list of tuples in Python

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

A list can have tuples as its elements. In this article we will learn how to identify those tuples which contain a specific search element from a list of tuples using different methods. Using List Comprehension with Condition We can use list comprehension with a conditional statement to filter tuples that contain the target element ? listA = [('Mon', 3), ('Tue', 1), ('Mon', 2), ('Wed', 3)] test_elem = 'Mon' # Given list print("Given list:") print(listA) print("Check value:") print(test_elem) # Using list comprehension with condition res = [item for item in listA if item[0] == ...

Read More

How to set the content as a counter?

Abhishek
Abhishek
Updated on 15-Mar-2026 334 Views

CSS counters allow you to automatically number elements on a web page without JavaScript. They work by creating variables that can be incremented and displayed as content using pseudo-elements like ::before and ::after. Syntax /* Reset/create counter */ parent-element { counter-reset: counter-name; } /* Increment and display counter */ element::before { counter-increment: counter-name; content: counter(counter-name); } CSS Counter Properties counter-reset − Creates or resets a counter to zero (or specified value) counter-increment ...

Read More

Find the Number Occurring Odd Number of Times using Lambda expression and reduce function in Python

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

In this article, we need to find a number from a list that occurs an odd number of times. We'll use Python's lambda function with the reduce() function to solve this problem efficiently. The key insight is using the XOR (^) operation, which has a special property: when you XOR a number with itself, the result is 0. This means numbers appearing an even number of times will cancel out, leaving only the number that appears an odd number of times. How XOR Works for This Problem Let's understand the XOR logic with a simple example: ...

Read More

How to set position of an image in CSS?

Abhishek
Abhishek
Updated on 15-Mar-2026 2K+ Views

In general, the default position of an image is left aligned on the web page. But you can change the position of an image according to your needs and set the position of an image manually on the web page where you have to show that particular image. Let us now discuss about the ways of positioning an image on the webpage using CSS. There are two methods or approaches in general to position an image on the web page using CSS that are listed below − Using the float property of CSS ...

Read More

Find the list elements starting with specific letter in Python

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

In this article, we will explore different methods to find all elements from a list that start with a specific letter. Python provides several approaches to achieve this efficiently. Using Index and lower() This method uses the lower() function to make the comparison case-insensitive. We access the first character of each element using index [0] and compare it with the test letter ? days = ['Mon', 'Tue', 'Wed', 'Thu'] test_letter = 'T' print("Given list:") print(days) # Using lower() and index to find elements starting with specific letter result = [item for item in days ...

Read More

Find most frequent element in a list in Python

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

In this article, we will see how to find the element which is most common in a given list. In other words, the element with the highest frequency. Python provides several approaches to solve this problem efficiently. Using max() and count() We apply the set() function to get unique elements of the list, then use count() to find the frequency of each element. Finally, we apply max() with a key function to get the element with the highest frequency. Example # Given list numbers = [45, 20, 11, 50, 17, 45, 50, 13, 45] print("Given ...

Read More

How to set padding inside an element using CSS?

Abhishek
Abhishek
Updated on 15-Mar-2026 952 Views

Padding in CSS creates space between an element's content and its border. This inner spacing helps improve readability and visual appeal by preventing content from touching the element's edges directly. Syntax /* Shorthand property */ padding: value; padding: top-bottom left-right; padding: top left-right bottom; padding: top right bottom left; /* Individual properties */ padding-top: value; padding-right: value; padding-bottom: value; padding-left: value; Possible Values Value TypeDescriptionExample LengthFixed units like px, em, rem10px, 1.5em PercentageRelative to parent element's width5%, 10% autoBrowser calculates paddingauto Method 1: Using Shorthand Padding Property The shorthand ...

Read More
Showing 19471–19480 of 61,299 articles
Advertisements