for multiple duplicate elements: num=int(input()) l=[int(input()) for i in range(num)] orig=[] dup=[] for i in l: if i not in orig: orig.append(i) else: dup.append(i) print(l) print(orig) print(dup)
@Abkklp2 жыл бұрын
Dear sister your effort are very special. God bless you
@rahatsshowcase86143 жыл бұрын
i was building a massive python bot and stuck in this simple algorithm!! XD But thanks sister! For Saving my time !!
@AmulsAcademy3 жыл бұрын
Pleasure 😊
@tesfalemhaile84275 жыл бұрын
I really look forward to your videos as I think you're method of teaching is really good. Keep up , and please make video about Archive fils THANK YOU
@AmulsAcademy5 жыл бұрын
Thank you :)
@technoinfoworldwide23294 жыл бұрын
i am quarantine at home, and next semester is my intern..so utilizing the time looking this type of your video..subscribed..make more video mam
@shohailaamil12384 жыл бұрын
Similar to me
@sujalgandha13253 жыл бұрын
You are teaching very good.Can you make video for this question: Write user defined function to show scope of global and local variables. In python.
@pedrocastro8823 жыл бұрын
thank you so much you saved my project
@AmulsAcademy3 жыл бұрын
Glad to hear that :)
@Kavithaofficial20042 жыл бұрын
Nice it's really helpful and understandable...அருமை✨☺️
@jeevatamilan97775 жыл бұрын
Wow amazing superb your explanation is very clear👏👏👏
@AmulsAcademy5 жыл бұрын
Thank you :)
@Just_Code444 Жыл бұрын
Thanks a lot for the explanation
4 жыл бұрын
you are genius
@AmulsAcademy4 жыл бұрын
Thank you :)
@shiningcopper3 жыл бұрын
beautiful and simple. just two lines.
@AmulsAcademy3 жыл бұрын
Thank you :)
@monoranjanchakraborty12795 жыл бұрын
mam your are really good
@AmulsAcademy5 жыл бұрын
Thank you :)
@jaiprasadkowru1322 Жыл бұрын
Thanks ❤
@saurabhamrutkar34972 жыл бұрын
can you please tell, How to perform same operation for nested in list...?
@buvaneshkumar56264 жыл бұрын
I see you're hard coding the repeated element in the code. But in most cases, we won't be knowing what was the repeated element.
@vasundharajayswal54513 жыл бұрын
def dup_elmnt(list1): indx_list=[] temp=[] for j in list1: if list1.count(j)>=2 and j not in temp: for i in range(len(list1)): if list1[i]==j: indx_list.append(i) temp.append(j) else: pass return indx_list
@sasidharreddy50086 ай бұрын
Here you know the duplicate values and you added them in the if condition and got those indexes what if you dont the elements which got duplicated in such cases how to do.?
@minalhombre68214 жыл бұрын
Thank you.
@AmulsAcademy4 жыл бұрын
You're welcome! :)
@sahiltikku69705 жыл бұрын
You are good
@AmulsAcademy5 жыл бұрын
Thank you :)
@Leo1979993 жыл бұрын
Thank you!!!
@kerubananthang29852 жыл бұрын
Is it possible to print the multiple duplicate element's index at same time??
@eswarkalakata51834 жыл бұрын
#finding the index for diplicate eliments l = [1,2,3,3,1,0,1] count = 0 s = set() v = [] for indx,value in enumerate(l): if value not in s: s.add(value) else: v.append([value,indx]) print(v)
@javierLopez-zb3oe4 жыл бұрын
Is there a super efficient way to do this? I tried with panda and it takes about the same time. I'm dealing with lists of 100k elements. Any advice? I'd really appreciate it! Thanks!
@daveclosinger66974 жыл бұрын
Find them by hand manually
@ahsanmomin4110 Жыл бұрын
names=['alex','hannahe','james'] Find how many 'e' and 'a' are there in list output [2,3,2] How to solve this one please asist??
@yukeshteach11813 ай бұрын
l1=["alex","hannahe","james"] #to find out no of and e l2=[] a="" count=0 for i in range(0,len(l1)): a=l1[i] count=0 for j in range(0,len(a)): if a[j]=='a'or a[j]=='e': count=count+1 l2.append(count) print(l2)
@Pardhu-g5g3 ай бұрын
nice question osm
@bhavanapanwar92584 жыл бұрын
thnq ...
@AmulsAcademy4 жыл бұрын
Welcome :)
@rajeshs28405 жыл бұрын
This code will give index of non duplicate numbers also. Sloppy code
@keshavmittal63655 жыл бұрын
Mam how can we make similar program when we input the list values from user and we don't know the repeated values
@AmulsAcademy5 жыл бұрын
n = int(input("How many elements you want in list:")) list1 = [] for i in range(n): list1.append(eval(input())) print("input list is:",list1) elem = eval(input("select the element: ")) list2 = [i for i in range(len(list1)) if list1[i]==elem] print("index of",elem,"is:",list2) :)
@keshavmittal63655 жыл бұрын
@@AmulsAcademy thank you
@CrazyFunCricket3 жыл бұрын
you have hardcoded the 1 its bad
@harpreetsidhu6064 жыл бұрын
i know that we can know the first occurence of the element by index method in lists,but can we do this same with because sets are unordered and unchangeable sometimes it prints only duplicate elements or without duplicate elements.like union( ) and update method exclude duplicate elements.
@neetuchauhan31375 жыл бұрын
nice please tell me that which is the best laptop for programming and hacking
@archu684 жыл бұрын
Can u make a program in python to check is user name valid or not
@AmulsAcademy4 жыл бұрын
I will try :)
@abdulhaleem78865 жыл бұрын
helloo.. can we add else statement to the above code??
@AmulsAcademy5 жыл бұрын
Yes :)
@keishalorejo72173 жыл бұрын
how do you do this in java?
@harpreetsidhu6064 жыл бұрын
also how can i make money from python becouse i know python, java, c#,c++,c as well as javascript html and css(cascading style sheets).what can i do for passive income
@karuma.-76184 жыл бұрын
Work for google, or big companies that require such skills, most pay a huge salary, especially in the medical field.
@omsrisaikrishna96185 жыл бұрын
Please tell me, how it will be compiler run step by step
@AmulsAcademy5 жыл бұрын
That program will print all the index of given duplicate element in list. 1 take a list with duplicate values. 2. we are using list comprehension method, i for i in range(len(list1)) ---------------------> it will print all the index of list element. but we want index of particular duplicate element, for example 1. so i will take if list1[i] == 1 condition. so it will give all the index duplicate element 1. 3 .next we will print that. :)
@omsrisaikrishna96185 жыл бұрын
@@AmulsAcademy thank you
@kabeerbasha3264 жыл бұрын
hello every one i have a number = 963 but i want output like this 18 is it possible
@AmulsAcademy4 жыл бұрын
num = int(input("num:")) result=0 str_num = str(num) for i in str_num: result = result+int(i) print(result) :)
@kabeerbasha3264 жыл бұрын
@@AmulsAcademy Thank you so much Amuls :)
@swapnilw.3 жыл бұрын
@@AmulsAcademy wow first 2 min. i didnt understand
@malikshehryar6965 жыл бұрын
please do this for gerenal code
@AmulsAcademy5 жыл бұрын
It will work for any list. If you want to take user entered list then, instead of taking list directly take like this. num = int(input("enter the list length:")) list1 = [int(input()) for i in range(num)] :)
@kennethdomingo36814 жыл бұрын
List1 = [ken, di, py] #firstname List2 = [py, thon, prog] #lastname List2 = [3,3,1] #grades How to get the max or min grades with getting the parralel index of list 1 and list2 My prob is only 0 index is readable But i need output is Ken py 3 Di thon 3
@technicalanalytics13914 жыл бұрын
Second Maximum Number in a List Description Given a list of numbers, find the second largest number in the list. Note: There might be repeated numbers in the list. If there is only one number present in the list, return 'not present'. Examples: Input 1: [7, 2, 0, 9, -1, 8] Output 1: 8 Input 2: [3, 1, 4, 4, 5, 5, 5, 0, 2, 2] Output 2: 4 Input 2: [6, 6, 6, 6, 6] Output 2: not present can you explain this problem