Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2020
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. dnk = str(input())
  2. new_dnk = ''
  3. algo = []
  4. old_dnk = ''
  5.  
  6. for i in dnk:
  7. if dnk.count(i) >= 2 and i not in new_dnk:
  8. new_dnk += i + str(dnk.count(i))
  9. algo.append(i)
  10. algo.append(str(dnk.count(i)))
  11. elif i not in new_dnk:
  12. new_dnk += i
  13. algo.append(i)
  14. print(new_dnk)
  15.  
  16. for i in range(len(algo)):
  17. d = i + 1
  18. try:
  19. old_dnk += algo[i] * int(algo[d])
  20. i += 1
  21. except:
  22. if algo[i].isdigit() == True:
  23. pass
  24. else:
  25. old_dnk += algo[i]
  26.  
  27. print(old_dnk)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement