Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. #!/bin/env python
  2.  
  3. s=input()
  4. h=''
  5. count=''
  6. uz=''
  7. for x in s:
  8.     if x.isalpha():
  9.         if h != '':
  10.             uz+=h*(1 if count =='' else int(count))
  11.         h=x
  12.         count=''
  13.     elif x.isdigit():
  14.         count+=x
  15.     else:
  16.         if h != '':
  17.             uz+=h*(1 if count =='' else int(count))        
  18.         #should not happen for our case. input could be invalid
  19.         count=''
  20.         h=''
  21.         #warn if necessary
  22. if h != '':
  23.     uz+=h*(1 if count =='' else int(count))
  24.    
  25. print(uz)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement