#1. 1. Write a python function that returns the index of the smallest element in a list of integers. If the number of such elements is greater than 1, return the smallest index.
def indexOfSmallestElement(lst):
print("index of smallest element:",list1.index(min(list1)))
list1=[]
n= int(input("Enter number of elements in the list:"))
for i in range(0,n):
lst=input()
list1.append(lst)
print("list1:",list1)
indexOfSmallestElement(list1)
Enter number of elements in the list:6 2 3 4 5 6 4 list1: ['2', '3', '4', '5', '6', '4'] index of smallest element: 0
#2.Write the python function mostCommonName
list1=[]
list2=[]
n= int(input("Enter number of elements in the list:"))
for i in range(0,n):
lst=input()
list1.append(lst)
print("input list1:",list1)
for i in list1:
if(list1.count(i) > 1):
list2.append(i)
print(set(list2))
Enter number of elements in the list:6 reva tre tre reva tgh yhk input list1: ['reva', 'tre', 'tre', 'reva', 'tgh', 'yhk'] {'tre', 'reva'}
#3.Write the python function isPalindromicList(a) that takes a list and returns True if it is the same forwards as backwards and False otherwise.
def isPalindromicList(list1):
flag=0
list2=[]
list2.extend(list1)
list1.reverse()
for i in range(len(list1)):
if list1[i] == list2[i]:
i+=1
flag=1
else:
flag=0
break
if flag == 1:
return True
else:
return False
list1=[]
n= int(input("Enter number of elements in the list:"))
for i in range(0,n):
lst=input()
list1.append(lst)
print(isPalindromicList(list1))
Enter number of elements in the list:5 1 2 1 2 1 True