List Programs

Python programs focused on list creation, traversal, searching, modification, and set-like operations.

25 program solutions

Back to Topics

Program Solutions

1

Sum of List Elements

Calculate the sum of all elements in a list of numbers.

Beginner
View Solution
2

Largest Element in List

Find the largest element in a list of numbers.

Beginner
View Solution
3

Smallest Element in List

Find the smallest element in a list of numbers.

Beginner
View Solution
4

Count Occurrences in List

Count how many times a given element occurs in a list.

Beginner
View Solution
5

Remove Duplicates from List

Remove duplicate elements from a list while preserving order.

Beginner
View Solution
6

Merge Two Lists

Merge two lists into a single list.

Beginner
View Solution
7

Intersection of Lists

Find the common elements between two lists.

Beginner
View Solution
8

Union of Lists

Find the union of two lists (unique elements from both).

Beginner
View Solution
9

Sort List

Sort a list of numbers in ascending order.

Beginner
View Solution
10

Reverse List

Reverse a list in-place using slicing.

Beginner
View Solution
11

Check if List is Sorted

Check whether a list is sorted in non-decreasing order.

Beginner
View Solution
12

Find Second Largest Element

Find the second largest distinct element in a list.

Beginner
View Solution
13

Find N Largest Elements

Find the N largest elements in a list.

Beginner
View Solution
14

Clone / Copy List

Create a shallow copy of a list.

Beginner
View Solution
15

Rotate List

Rotate a list by K positions to the right.

Beginner
View Solution
16

Remove Empty Lists

Remove empty sublists from a list of lists.

Beginner
View Solution
17

Flatten Nested List

Flatten a shallow nested list (list of lists) into a single list.

Intermediate
View Solution
18

Find Common Elements of Two Lists

Find elements that appear in both lists (preserving list order of the first).

Beginner
View Solution
19

List Slicing Programs

Demonstrate common list slicing operations (first N, last N, every Kth element).

Beginner
View Solution
20

Replace List Elements

Replace all occurrences of a value in a list with another value.

Beginner
View Solution
21

Remove Element by Value

Remove the first occurrence of a value from a list, if present.

Beginner
View Solution
22

Count Prime Numbers in List

Count how many prime numbers are present in a list of integers.

Intermediate
View Solution
23

Pair Sum Problem

Check if there exists a pair of numbers in the list that adds up to a target sum.

Intermediate
View Solution
24

Unique Elements from Both Lists

Find elements that appear in exactly one of the two lists (symmetric difference).

Intermediate
View Solution
25

List Difference

Find elements that are in the first list but not in the second.

Beginner
View Solution