Question: In this assignment you will practice: command-line arguments, loops, counting, and comparing values in Python. Write a program that determines if a string (passed as

In this assignment you will practice: command-line arguments, loops, counting, and comparing

values in Python.

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.

C:\>python unique.py "My string!"

M : 1

y : 1

: 1

s : 1

t : 1

r : 1

i : 1

n : 1

g : 1

! : 1

Unique! All characters appear only once.

WHAT TO SUBMIT:

name your program unique.py and submit on Canvas.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!