def indexOfSmallestElement(lst):
length = len(lst)
smallest_num =lst[0]
small_index = 0
for i in range (1,length):
if lst[i]<smallest_num:
smallest_num =lst[i]
small_index=i
return small_index
print(indexOfSmallestElement([4,2,1,6,2,7,1]))
2
def most_frequent(List):
counter = 0
num = List[0]
length = len(List)
i = 0
#for getting frequency of each element after that
while i < length:
curr_frequency = List.count(List[i])
if(curr_frequency> counter):
counter = curr_frequency
num = List[i]
i += 1
result = [num]
i = 0
#this is for same frequency exist for another element in the list
while i < length:
curr_frequency = List.count(List[i])
if(curr_frequency == counter and List[i] not in result):
result.append(List[i])
i += 1
#this is for sorting
result.sort()
return result
#driver code
List = ['Jane', 'Cindy', 'Aaron','Aaron','Jane']
print(most_frequent(List))
['Aaron', 'Jane']
S = input("Input a word: ")
def isPalindrome(S):
for i in range(0, len(S)):
if S[0 + i] == S[len(S) - 1]:
return "True"
else:
return "False"
print(isPalindrome(S))
Input a word: malayalam True