-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterchange3.py
More file actions
28 lines (21 loc) · 763 Bytes
/
Copy pathInterchange3.py
File metadata and controls
28 lines (21 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""
Interchange the Elements
"""
class InterchangeSecond:
"""Interchange third Element with third element from last """
def __init__(self):
self.elements = []
def exchange_elements(self):
print(f"Before exchange:{self.elements}")
temp = self.elements[2]
self.elements[2] = self.elements[-3]
self.elements[-3] = temp
print(f"After exchange: {self.elements}")
def get_input(self):
length = int(input("Enter length of list:"))
for el in range(length):
self.elements.append(int(input(f"Enter element for {el}th index")))
if __name__ == '__main__':
interchangeSecond = InterchangeSecond()
interchangeSecond.get_input()
interchangeSecond.exchange_elements()