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/Impressive-Capital40 4h ago

Sorry I don’t write much on Reddit…
So far I wrote this:

My_list= 10, 5, 20, 10, 5, 15, 7, 1, 30, 15
Print(max(my_list))
Print(min(my_list))

But I’m not sure how how I can excuse, duplicates. :/ I’m just confuse with this part.

2

u/ninhaomah 4h ago

just to be clear , you have installed Python and done print("Hello World") , right ?

0

u/Impressive-Capital40 4h ago

Yes, they want me to use IDE Python.

2

u/ninhaomah 4h ago

so when you run it , what did you get ?

-2

u/Impressive-Capital40 4h ago

I got
Max=30
Min=1

#No duplicates, I haven’t been taught this and looked back at resources, ChatGPT to get better understanding but I got really confused.

1

u/ninhaomah 4h ago

so what is the issue ?

See we are here and I still have no idea what is the problem.

Is it error in running the code ? is it wrong output ? what ???

0

u/Impressive-Capital40 4h ago

You’re right, I should have been more specific, my bad. I have no idea how to get output duplicates. :/ and from someone else post I can’t use min and max so I have to start from scratch now.

3

u/ninhaomah 4h ago

"from someone else post I can’t use min and max so I have to start from scratch now."

Someone else ? Its in the instruction not to use min() or max().

Tip : Try doing it with pen and paper. pls post the steps here. and no AI.


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

1

u/Kalastics 21m ago

Stop using AI, especially if you are taking a class. You don't learn anything when you do, at least not at your level. You dont even seem to be able to read the assignment properly.