Home› Python Programming Language› / Programs / Remove duplicates from a list and create a tuple and find the minimum and maximum number
🚀 Programming Example

Remove duplicates from a list and create a tuple and find the minimum and maximum number

248 Views
Beginner
Code Snippet
Remove duplicates from a list and create a tuple and find the minimum and maximum number

📌 Information & Algorithm

Given Input:

sample_list = [87, 45, 41, 65, 94, 41, 99, 94]

Expected Output:

unique items [87, 45, 41, 65, 99]
tuple (87, 45, 41, 65, 99)
min: 41
max: 99

💻 Program Code

sample_list = [87, 52, 44, 53, 54, 87, 52, 53]

print("Original list", sample_list)

sample_list = list(set(sample_list))
print("unique list", sample_list)

t = tuple(sample_list)
print("tuple ", t)

print("Minimum number is: ", min(t))
print("Maximum number is: ", max(t))

🖥 Program Output

                                Original list [87, 52, 44, 53, 54, 87, 52, 53]
unique list [44, 52, 53, 54, 87]
tuple  (44, 52, 53, 54, 87)
Minimum number is:  44
Maximum number is:  87
                            
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.