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

python find duplicates in string

from collections import Counter

def do_find_duplicates(x):
    x =input("Enter a word = ")
    for key,val in Counter(x).items():
        print(key,val)
Comment

PREVIOUS NEXT
Code Example
Python :: os.system return value 
Python :: save machine learning model 
Python :: pyqt5 set window icon 
Python :: how to increase the figure size in matplotlib 
Python :: get longest shortest word in list python 
Python :: python selenium hover over element 
Python :: how to add button in tkinter 
Python :: django register models 
Python :: python underscore variable 
Python :: pip install numpy 
Python :: pandas dataframe set datetime index 
Python :: python border 
Python :: how to open any application using python 
Python :: python auto module installer 
Python :: split string form url last slash 
Python :: tkinter entry default value 
Python :: rotate x label 90 degrees seaborn 
Python :: time decorator python 
Python :: python code region 
Python :: discord.py clear command 
Python :: python app to deb 
Python :: user agent for python 
Python :: werkzeug.datastructures.filestorage to numpy 
Python :: pandas concat and reset index 
Python :: python reference script directory 
Python :: generate python date list 
Python :: sort two lists by one python 
Python :: read database pandas 
Python :: python read csv 
Python :: set icon title tkinter 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =