Part of the series

Several example codes

~1 min read • Updated Oct 1, 2025

Program Overview

This Python program reads a list of integers from the user.
It calculates and displays the minimum value, maximum value, and any shared (duplicate) values in the list.


Python Code:


# Read a list of integers from the user
numbers = list(map(int, input("Enter integers separated by space: ").split()))

# Calculate minimum and maximum
min_val = min(numbers)
max_val = max(numbers)

# Find shared (duplicate) values
duplicates = set([x for x in numbers if numbers.count(x) > 1])

# Display results
print("\n--- Result ---")
print(f"Minimum value: {min_val}")
print(f"Maximum value: {max_val}")
print(f"Shared values: {sorted(duplicates) if duplicates else 'None'}")

Sample Output:


Enter integers separated by space: 12 45 7 12 89 45 3  

--- Result ---
Minimum value: 3  
Maximum value: 89  
Shared values: [12, 45]

Step-by-Step Explanation:

- The user inputs a space-separated list of integers
- The program uses min() and max() to find the smallest and largest values
- A list comprehension identifies values that appear more than once
- Results are printed in a clean format


Written & researched by Dr. Shahin Siami