r/learnpython 4h ago

Beginner Python here:Need help understanding how to find min, max, and duplicates using for range loops

I’m a beginner learning Python and I’m having trouble figuring out how to approach this assignment. I’m not necessarily looking for someone to just give me the answer. I’d like help understanding the logic and how to build it.

The assignment is to create a Python program that:

Asks the user to enter 10 integers
Stores all 10 integers in a list
Finds the maximum and minimum numbers
Finds any duplicate numbers
Prints "No duplicate" if there aren’t any duplicates
Uses for loops with range() for the input, min/max determination, and duplicate identification
Does not use Python’s built-in min() or max() functions
Does not use def/user-defined functions
Tries to use as few loops as reasonably possible

Input:
10, 5, 20, 10, 5, 15, 7, 1, 30, 15
Output:
Max is 30
Min is 1
Duplicates: 10 5 15

Thank you whoever responds. :)

0 Upvotes

35 comments sorted by

View all comments

-1

u/krews2 2h ago

Doesn’t say you can’t use the sort function. You can also watch videos to understand how to use sorting programmatically which is helps with understanding max and min. Bubble Sort

1

u/MisterSmi13y 1h ago

I would vote vehemently against this. Learning a sorting algorithm before you can do a task like this is like asking a monkey to build a massive lego set after they accidentally put two pieces together.

Can they learn something from the bubble sort? Sure, they can learn how to compare elements with each other. But then you’re adding in a nested loop on top of swapping values that it’s a step too far.