def indexofsmallest(numbers):
return numbers.index(min(numbers))+1
print(indexofsmallest([23, 3, 6, 5, 12, 9, 7, 4]))
2
def most_frequent(List):
counter = 0
num = List[0]
for i in List:
curr_frequency = List.count(i)
if(curr_frequency> counter):
counter = curr_frequency
num = i
return num
List = ["Jane", "Aaron", "Cindy", "Aaron"]
print(most_frequent(List))
Aaron
def isPalindrome(a):
last = len(a)
middle = last >> 1
for i in range(middle):
last -= 1
if(a[i] != a[last]):
return False
return(True)
print("\n".join([str((word, isPalindrome(word))) for word in ["abcdcba", "abcdBba", "abccba", "abcBba", "a", ""]]))
('abcdcba', True) ('abcdBba', False) ('abccba', True) ('abcBba', False) ('a', True) ('', True)