Jun-04-2020, 02:55 PM
Find out duplicate number between 1 to N numbers. (anyone have a code)
program help
|
Jun-04-2020, 02:55 PM
Find out duplicate number between 1 to N numbers. (anyone have a code)
Jun-04-2020, 03:15 PM
You could try to add them to a set(), if a number fails, it is a duplicate.
Paul
It is more important to do the right thing, than to do the thing right.(P.Drucker)
Better is the enemy of good. (Montesquieu) = French version for 'kiss'.
2 basic ways :
list1 = [1,2,3,4,5,6,1,2,3] set1 = set(list1) print(list(set1))or list2 = [1,3,5,7,9,1,3] list3 = [] for i in list2: if i not in list3: list3.append(i) print(list3)
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela Need help on the forum? Visit help @ python forum For learning more and more about python, visit Python docs
Jun-04-2020, 05:21 PM
Unfortunately, you've been given solutions by now, but in future please try to come up with a solution before asking for help (pen and paper are great tools!). You need to develop problem solving skills as a programmer.
|
|