-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem3.py
More file actions
20 lines (19 loc) · 830 Bytes
/
problem3.py
File metadata and controls
20 lines (19 loc) · 830 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# important gyaan about reverse of list function in video https://youtu.be/tx7VofKNnAA from 7:30 approx
size = int(input("Enter the size of list\n"))
mylist = []
for i in range(size):
mylist.append(int(input("enter the elements of the list one by one \n")))
print(f"List you entered is {mylist}")
# mylist = [1,23,45,76]
print(f"your list is {mylist}")
reverse1 = mylist[:]
reverse1.reverse()
reverse2 = mylist[::-1]
print(f"the first reverse list is {reverse1}")
print(f"the second reverse list is {reverse2}")
reverse3 = mylist[:]
for i in range(len(reverse3) // 2):
reverse3[i] , reverse3[len(reverse3)-i-1] = reverse3[len(reverse3)-i-1] , reverse3[i]
print(f"the third reverse list is {reverse3}")
if reverse1 == reverse2 and reverse2 == reverse3 :
print("all the methods give same results")