Advertisement
JimZhou

task1-3

Oct 18th, 2019
127
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.     if len(x)>4:
  14.  
  15.         x_list = list(x)
  16.  
  17.         x_list[4:len(x)] = "."*(len(x)-4)
  18.  
  19.         x_list = ''.join(x_list)
  20.  
  21.         print(x_list,end=" , ")
  22.  
  23.     else:
  24.  
  25.         print(x,end=" , ")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement