Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

finding duplicate characters in a string python

#finds duplicate characters
def duplicatecharacters(s:str):
    for i in s:
        if s.count(i)>1:
            return True
    return False
print(duplicatecharacters(""))
Comment

count repeated characters in a string python

# Python 3+
import collections
collections.Counter(input_string)

# Python 2 or custom results.
{key: string.count(key) for key in set(string)}

# Other ways are too slow. In the source, You can see the proves.
Comment

PREVIOUS NEXT
Code Example
Python :: numpy find columns containing nan 
Python :: telebot send file 
Python :: type string python 
Python :: print p py pyt pyth pytho python in python 
Python :: python create function 
Python :: pygame zero how to draw text 
Python :: how to split a string by character in python 
Python :: python delete value from dictionary 
Python :: django queryset last 10 
Python :: check python version 
Python :: qtablewidget not editable python 
Python :: check anonim user django 
Python :: .argsort() python 
Python :: tabula python 
Python :: python add one 
Python :: how to read numbers in csv files python 
Python :: pyqt open file dialog 
Python :: python variables in multiline string 
Python :: python datetime offset 
Python :: check how many times a substring appears in a string 
Python :: lambda python 
Python :: print 2 decimal places python 
Python :: random number generator in python 
Python :: cartesian product pandas 
Python :: one line if statement without else 
Python :: count different values in list python 
Python :: import file in parent directory python 
Python :: pandas groupby mean round 
Python :: how to install api in python 
Python :: python invert binary tree 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =