Question: Write a program that determines if a string (passed as a command-line argument) has all unique characters. The program must print the number of times
Write a program that determines if a string (passed as a command-line argument) has all unique characters. The program must print the number of times each existing character appears, and then print whether or not they are all unique.
Special requirements: You are NOT allowed to modify the input string or create any additional data structures (no arrays, lists, dictionaries, or other strings). You may have only one string (the one received as the command-line argument). You may have one boolean variable and up to 3 integer variables (hint: one is the counter).
DO NOT use any built-in String methods, such as the ones listed here: https://www.w3schools.com/python/python_ref_string.asp
Input validation: You must print a friendly error message and end execution if the program does not receive any arguments from the command-line.
Here are some sample runs:
C:\>python unique.py Usage: python unique.py "Any string you want..." C:\>python unique.py This is a string! Usage: python unique.py "Any string you want..." C:\>python unique.py "This is a string!"
T : 1 h : 1 i : 3 s : 3 : 3 i : 3 s : 3 : 3 a : 1 : 3 s : 3 t : 1 r : 1 i : 3 n : 1 g : 1 ! : 1
Not unique! One or more characters appear more than once.
Step by Step Solution
There are 3 Steps involved in it
To solve this problem we need to write a Python program that checks a given string for uniqueness in characters without modifying the string or using ... View full answer
Get step-by-step solutions from verified subject matter experts
