-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterchange4.py
More file actions
24 lines (19 loc) · 773 Bytes
/
Copy pathinterchange4.py
File metadata and controls
24 lines (19 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"""this program interchange the 4th element with 4th last element of a list"""
class Interchange4:
"class to interchange the elements of list"
def __init__(self):
self.elements =[]
def get_input(self):
length = int(input("enter the elements:"))
for el in range(length):
self.elements.append(int(input(f"Enter element for {el} index: ")))
def exchange_elements(self):
print(f'before exchange elements: {self.elements}')
temp = self.elements[3]
self.elements[3]=self.elements[-4]
self.elements[-4]= temp
print(f'after exchange elements: {self.elements}')
if __name__=='__main__':
interchange=Interchange4()
interchange.get_input()
interchange.exchange_elements()