A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
Welcome to the Duplicate Character Counter in Python page! Here, you'll find the source code for this program as well as a description of how the program works.
import sys
if len(sys.argv) != 2 or not sys.argv[1]:
print("Usage: please provide a string")
sys.exit()
counter = dict()
dupes = False
for char in sys.argv[1]:
counter.setdefault(char, 0)
counter[char] += 1
if counter[char] > 1:
dupes = True
if dupes:
for key, value in counter.items():
if value > 1:
print(f"{key}: {value}")
else:
print("No duplicate characters")
Duplicate Character Counter in Python was written by:
If you see anything you'd like to change or update, please consider contributing.
No 'How to Implement the Solution' section available. Please consider contributing.
No 'How to Run the Solution' section available. Please consider contributing.