From 2ac42fa825d403e6285a58e08a62e6d549c86fa1 Mon Sep 17 00:00:00 2001 From: thing1 Date: Mon, 3 Mar 2025 08:07:43 +0000 Subject: started elcectronics cw2 --- comp/work/45/paircount.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 comp/work/45/paircount.py (limited to 'comp/work/45') diff --git a/comp/work/45/paircount.py b/comp/work/45/paircount.py new file mode 100644 index 0000000..c9af5f0 --- /dev/null +++ b/comp/work/45/paircount.py @@ -0,0 +1,23 @@ +word = input("input your word: ") + ' ' + +pairs = "" + +for i in range(1, len(word)): + if word[i] == word[i-1]: + pairs += word[i] + print(word[i-1].upper(), end='') + else: + print(word[i-1], end='') +print("") + +done = "" +total = 0 + +for i in pairs: + if (i not in done): + done += i + total += pairs.count(i) + print(f"you have {pairs.count(i)} pairs of {i}") + +print("you have", total, "pairs total") + -- cgit v1.2.3