Python Program To Print Every Index of Duplicate Elements in List

Поделиться
HTML-код
  • Опубликовано: 1 ноя 2024

Комментарии • 70

  • @pavankumarlucky5963
    @pavankumarlucky5963 3 года назад +10

    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)

  • @tesfalemhaile8427
    @tesfalemhaile8427 5 лет назад +9

    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

  • @rahatsshowcase8614
    @rahatsshowcase8614 3 года назад +1

    i was building a massive python bot and stuck in this simple algorithm!! XD But thanks sister! For Saving my time !!

  • @Abkklp
    @Abkklp 2 года назад

    Dear sister your effort are very special. God bless you

  • @sujalgandha1325
    @sujalgandha1325 3 года назад +1

    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.

  • @Kavithaofficial2004
    @Kavithaofficial2004 2 года назад

    Nice it's really helpful and understandable...அருமை✨☺️

  • @pedrocastro882
    @pedrocastro882 3 года назад +1

    thank you so much you saved my project

  • @technoinfoworldwide2329
    @technoinfoworldwide2329 4 года назад +1

    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

  • @jeevatamilan9777
    @jeevatamilan9777 5 лет назад +1

    Wow amazing superb your explanation is very clear👏👏👏

  • @shiningcopper
    @shiningcopper 3 года назад +2

    beautiful and simple. just two lines.

  • @Just_Code444
    @Just_Code444 Год назад

    Thanks a lot for the explanation

  •  4 года назад +1

    you are genius

  • @saurabhamrutkar3497
    @saurabhamrutkar3497 2 года назад +1

    can you please tell, How to perform same operation for nested in list...?

  • @monoranjanchakraborty1279
    @monoranjanchakraborty1279 5 лет назад +1

    mam your are really good

  • @javierLopez-zb3oe
    @javierLopez-zb3oe 4 года назад +2

    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!

  • @jaiprasadkowru1322
    @jaiprasadkowru1322 Год назад

    Thanks ❤

  • @sasidharreddy5008
    @sasidharreddy5008 6 месяцев назад

    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.?

  • @kerubananthang2985
    @kerubananthang2985 2 года назад

    Is it possible to print the multiple duplicate element's index at same time??

  • @minalhombre6821
    @minalhombre6821 4 года назад +1

    Thank you.

  • @Pardhu-g5g
    @Pardhu-g5g 3 месяца назад

    nice question osm

  • @sahiltikku6970
    @sahiltikku6970 5 лет назад +1

    You are good

  • @Leo197999
    @Leo197999 3 года назад

    Thank you!!!

  • @abdulhaleem7886
    @abdulhaleem7886 5 лет назад +1

    helloo.. can we add else statement to the above code??

  • @keshavmittal6365
    @keshavmittal6365 5 лет назад +2

    Mam how can we make similar program when we input the list values from user and we don't know the repeated values

    • @AmulsAcademy
      @AmulsAcademy  5 лет назад

      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)
      :)

    • @keshavmittal6365
      @keshavmittal6365 5 лет назад +1

      @@AmulsAcademy thank you

  • @ahsanmomin4110
    @ahsanmomin4110 Год назад +1

    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??

    • @yukeshteach1181
      @yukeshteach1181 2 месяца назад

      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)

  • @bhavanapanwar9258
    @bhavanapanwar9258 4 года назад +1

    thnq ...

  • @buvaneshkumar5626
    @buvaneshkumar5626 4 года назад +7

    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.

    • @vasundharajayswal5451
      @vasundharajayswal5451 3 года назад

      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

  • @harpreetsidhu606
    @harpreetsidhu606 4 года назад

    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.

  • @neetuchauhan3137
    @neetuchauhan3137 5 лет назад

    nice please tell me that which is the best laptop for programming and hacking

  • @archu68
    @archu68 4 года назад +1

    Can u make a program in python to check is user name valid or not

  • @omsrisaikrishna9618
    @omsrisaikrishna9618 5 лет назад +1

    Please tell me, how it will be compiler run step by step

    • @AmulsAcademy
      @AmulsAcademy  5 лет назад +1

      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.
      :)

    • @omsrisaikrishna9618
      @omsrisaikrishna9618 5 лет назад +1

      @@AmulsAcademy thank you

  • @keishalorejo7217
    @keishalorejo7217 3 года назад

    how do you do this in java?

  • @harpreetsidhu606
    @harpreetsidhu606 4 года назад

    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.-7618
      @karuma.-7618 3 года назад

      Work for google, or big companies that require such skills, most pay a huge salary, especially in the medical field.

  • @rajeshs2840
    @rajeshs2840 5 лет назад +1

    This code will give index of non duplicate numbers also. Sloppy code

  • @malikshehryar696
    @malikshehryar696 5 лет назад +1

    please do this for gerenal code

    • @AmulsAcademy
      @AmulsAcademy  5 лет назад +1

      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)]
      :)

  • @kabeerbasha326
    @kabeerbasha326 4 года назад +2

    hello every one i have a number = 963 but i want output like this 18 is it possible

    • @AmulsAcademy
      @AmulsAcademy  4 года назад +4

      num = int(input("num:"))
      result=0
      str_num = str(num)
      for i in str_num:
      result = result+int(i)
      print(result)
      :)

    • @kabeerbasha326
      @kabeerbasha326 4 года назад +1

      @@AmulsAcademy Thank you so much Amuls :)

    • @swapnilw.
      @swapnilw. 3 года назад

      @@AmulsAcademy wow first 2 min. i didnt understand

  • @eswarkalakata5183
    @eswarkalakata5183 4 года назад +2

    #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)

  • @CrazyFunCricket
    @CrazyFunCricket 3 года назад +1

    you have hardcoded the 1 its bad

  • @mandeepubhi4744
    @mandeepubhi4744 5 лет назад +1

    Awesome

  • @technicalanalytics1391
    @technicalanalytics1391 4 года назад +1

    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

    • @AmulsAcademy
      @AmulsAcademy  4 года назад

      I will try to make a video on that :)

  • @kennethdomingo3681
    @kennethdomingo3681 4 года назад

    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