Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def swap_operation(the_list, index1, index2):
- new_list = the_list[:]
- if index1 < 0 or index1 > len(the_list) - 1 or index2 < 0 or index2 > len(the_list) - 1 or index1 > index2:
- print(*new_list)
- else:
- new_list[index1], new_list[index2] = new_list[index2], new_list[index1]
- print(*new_list)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement