Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- arr = ['hello' ',' , 'how', 'is' , 'your', 'day', 'going', '?' , '#', 'HelloWorld']
- N = 0
- for index to arr:
- if arr[N] == '#':
- arr[N] = (' ')
- arr[N+1] = (' ')
- N += 1
- arr = ['a', 'b', '#', 'aa']
- indices = [idx for idx, elt in enumerate(arr) if elt == '#']
- for idx in indices:
- if idx != len(arr): arr[idx+1] = ' ' # Check if not at the end of the list
- arr[idx] = ' '
- for i in range(len(arr)):
- if arr[i] == '#':
- arr[i] = ' '
- if i < len(arr)-2:
- arr[i+1] = ' '
- arr = ['hello' ',' , 'how', 'is' , 'your', 'day', 'going', '?' , '#', 'HelloWorld']
- for index in range(0, len(arr)):
- if arr[index] == '#':
- arr[index:index+2] = ['', '']
- print (arr)
- ['hello,', 'how', 'is', 'your', 'day', 'going', '?', '', '']
- [Finished in 0.133s]
- arr = ['hello' ',' , 'how', 'is' , 'your', 'day', 'going', '?' , '#', 'HelloWorld', '#']
- for index in range(0, len(arr)):
- if arr[index] == '#':
- arr[index:index+2] = ['', '']
- print (arr)
- ['hello,', 'how', 'is', 'your', 'day', 'going', '?', '', '', '', '']
- [Finished in 0.179s]
Add Comment
Please, Sign In to add comment