Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. def rle_mode(): #Decompresses user entered data
  2. abc = 1
  3. while abc == 1:
  4. try:#Catches errors
  5. linecount = int(input("How many lines of compressed data do you want to enter?"))#Inputs compressed data
  6. if linecount < 1000000000:
  7. abc = 0
  8. except ValueError:
  9. print("Please enter a number greater than 3")
  10. abc = 1
  11. while linecount < 3:
  12. abc = 1
  13. while abc == 1:
  14. try:
  15. linecount = int(input("Please enter a number greater than 3\nHow many lines of compressed data do you want to enter?"))
  16. if linecount < 1000000000:
  17. abc = 0
  18. except ValueError:
  19. abc = 1
  20. rle = []
  21. abcd = 1
  22. while abcd == 1:
  23. try:
  24. rle = []
  25. for i in range(0,linecount):
  26. rle.append(input("Please enter your compressed data, line by line: "))
  27. for i in range(0,len(rle)):
  28. for x in range(0, len(rle[i]), 3):
  29. print(int(rle[i][x:x+2]) * rle[i][x+2], end="")#Decompresses data
  30. abcd = 0
  31. print()
  32. except (IndexError, ValueError):
  33. print("Try again")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement