school

thing1's amazing school repo
Log | Files | Refs | Submodules | README

paircount.py (442B)


      1 word = input("input your word: ") + ' '
      2 
      3 pairs = ""
      4 
      5 for i in range(1, len(word)):
      6     if word[i] == word[i-1]:
      7         pairs += word[i]
      8         print(word[i-1].upper(), end='')
      9     else:
     10         print(word[i-1], end='')
     11 print("")
     12 
     13 done = ""
     14 total = 0
     15 
     16 for i in pairs:
     17     if (i not in done):
     18         done += i
     19         total += pairs.count(i)
     20         print(f"you have {pairs.count(i)} pairs of {i}")
     21 
     22 print("you have", total, "pairs total")
     23