Radeen10-_

Counting Duplicates

Aug 18th, 2021 (edited)
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. Write a function that will return the count of distinct case-insensitive alphabetic characters and numeric digits that occur more than once in the input string. The input string can be assumed to contain only alphabets (both uppercase and lowercase) and numeric digits.
  2. ---------------------------------------------------------------------------------------------------------------------------------------
  3. "aA11" -> 2 |'a' and '1' each occur twice
  4. "ABBA" -> 2 | 'A' and 'B' each occur twice
  5. ======================================================================================================================================
  6. def duplicate_count(text):
  7.     text=text.lower()
  8.     count1 =""
  9.     for i in range(0,len(text)):
  10.         for j in range(i+1,len(text)):
  11.             if text[i]==text[j] and text[i] not in count1:
  12.                 count1+=text[i]
  13.     return len(count1)
  14.  
Add Comment
Please, Sign In to add comment