aboutsummaryrefslogtreecommitdiff
path: root/challenge-180/deadmarshal/python/ch1.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-180/deadmarshal/python/ch1.py')
-rw-r--r--challenge-180/deadmarshal/python/ch1.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/challenge-180/deadmarshal/python/ch1.py b/challenge-180/deadmarshal/python/ch1.py
new file mode 100644
index 0000000000..a006f46cb3
--- /dev/null
+++ b/challenge-180/deadmarshal/python/ch1.py
@@ -0,0 +1,20 @@
+import sys
+
+def first_unique_character(s):
+ freq = {}
+ for i in s:
+ if i not in freq:
+ freq[i] = 1
+ else:
+ freq[i] += 1
+
+ for i in range(len(s)):
+ if(freq[s[i]] == 1):
+ return f"{i} as '{s[i]}' is the first unique character"
+ return -1
+
+if(len(sys.argv) != 2):
+ sys.stderr.write("No arg(s) provided!\n")
+ sys.exit(1)
+
+print(first_unique_character(sys.argv[1]))