Advertisement
JimZhou

task1-1

Oct 18th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. import re
  2.  
  3. str1 = "Welcome to _CEICData. Welcome to BPA; Wecome to ISI"
  4.  
  5. str1_list = re.split(r'[;,._ ]', str1)
  6.  
  7. while "" in str1_list:
  8.  
  9. str1_list.remove('')
  10.  
  11. for x in str1_list:
  12.  
  13.  
  14.  
  15.  
  16. if len(x)>4:
  17.  
  18.     x_list = list(x)
  19.  
  20.     x_list[4:len(x)] = "."*(len(x)-4)
  21.  
  22.     x_list = ''.join(x_list)
  23.  
  24.     print(x_list,end=" , ")
  25.  
  26. else:
  27.  
  28.     print(x,end=" , ")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement