Code with explanation:
def second_index(a_list,number):
#list of all occurance
lst=[i for i, n in enumerate(a_list) if n == number ]
if len(lst)>1:
return lst[1]
else:
return None
print(second_index([2,34,3,45,34,45,3,3],3))
print(second_index([2,34,3,45,34,45,3,3],45))
print(second_index([2,34,3,45,134,45,3,3],134))
print(second_index([2,34,3,45,134,45,3,3],100))
===============================================
screenshot of output with code:
![In [10]: def second_index(a_list, number): #list of all occurance 1st=[i for i, n in enumerate(a_list) if n == number ] if le](//img.homeworklib.com/questions/c0b0d210-0a95-11eb-a143-6fae29d5ccbb.png?x-oss-process=image/resize,w_560)
===========================================================================
Code with explanation:
def hasEveryLetter(s):
for x in s:
#check if the letter is lower
if x.islower():
#count the number of occurance of each letter
#in given string
cnt=[i for i, n in enumerate(s) if n == x]
#if occurance is greater than 1
#return False
if(len(cnt)>1):
return False
return True
print(hasEveryLetter("Apple"))
print(hasEveryLetter("aPPle"))
print(hasEveryLetter("bankruptcy"))
print(hasEveryLetter("Demography"))
===========================================
screenshot of output with code:
![In [20]: def hasEveryLetter(s): for x in s: #check if the letter is Lower if x.islower(): #count the number of occurance of e](//img.homeworklib.com/questions/c1145d30-0a95-11eb-a03f-abf618686bff.png?x-oss-process=image/resize,w_560)
![In [21]: def hasEveryLetter(s): for x in s: #check if the letter is Lower if x.islower(): #count the number of occurance of e](//img.homeworklib.com/questions/c18d6270-0a95-11eb-8c6d-b57328e3d3ff.png?x-oss-process=image/resize,w_560)
In [10]: def second_index(a_list, number): #list of all occurance 1st=[i for i, n in enumerate(a_list) if n == number ] if len(1st)>1: return Ist[1] else: return None print(second_index([2,34,3,45,34,45,3,3),3)) print(second_index([2,34,3,45,34,45,3,3),45)) print(second_index([2,34,3,45,134,45,3,3), 134)) print(second_index([2,34,3,45,134,45,3,3), 100)) 6 5 None None
In [20]: def hasEveryLetter(s): for x in s: #check if the letter is Lower if x.islower(): #count the number of occurance of each Letter #in given string cnt=[i for i, n in enumerate(s) if n == x] #if occurance is greater than 1 #return false if(len(cnt)>1): return false return True - print(hasEveryLetter("Apple")) print(hasEvery Letter("bankruptcy")) print(hasEveryLetter("Demography")) False True True
In [21]: def hasEveryLetter(s): for x in s: #check if the letter is Lower if x.islower(): #count the number of occurance of each Letter #in given string cnt=[i for i, n in enumerate(s) if n x] #if occurance is greater than 1 #return false if(len(cnt) >1): return false return True print(hasEveryLetter("Apple")) print(hasEveryLetter("aPPle")) print(hasEvery Letter("bankruptcy")) print(hasEveryLetter("Demography"))|| False True True True
.