Jamoliddin

Quest.42.uz. Task 4

May 11th, 2021 (edited)
470
328 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. alphabet = {
  2.     1: '.',
  3.     2: 'abc2',
  4.     3: 'def3',
  5.     4: 'ghi4',
  6.     5: 'jkl5',
  7.     6: 'mno6',
  8.     7: 'pqrs7',
  9.     8: 'tuv8',
  10.     9: 'wxyz9',
  11.     0: ' '
  12. }
  13.  
  14. with open('input_4_task.txt', 'r') as f:
  15.     l = f.readline()
  16.     start = False
  17.     temp = ''
  18.     count = 0
  19.     for i in l:
  20.         if start:
  21.             if i == temp:
  22.                 count += 1
  23.             else:
  24.                 if temp != '1':
  25.                     print(alphabet[int(temp)][count-1], end='')
  26.                 count = 1
  27.                 temp = i
  28.         else:
  29.             temp = i
  30.             count += 1
  31.             start = True
  32.  
  33.     print(alphabet[int(temp)][count - 1], end='')
  34.  
RAW Paste Data