prusev71

Merging and Squashing in python

Jun 12th, 2024
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | Software | 0 0
  1. n = int((input()))
  2.  
  3. line = []
  4.  
  5. for i in range(n):
  6.  
  7. num_i = input()
  8.  
  9. line.append(num_i)
  10.  
  11. line_s = str(''.join(line))
  12.  
  13. line_l = list(line_s)
  14.  
  15. line_l.pop(0) and line_l.pop()
  16.  
  17. for i in range(n-1):
  18.  
  19. line_l[i:i+2] = [''.join(line_l[i:i+2])]
  20.  
  21. output = ' '.join([str(el) for el in line_l])
  22.  
  23. print(output)
Tags: python
Advertisement
Add Comment
Please, Sign In to add comment