Question: How do I add a else clause to the loop for list a? if inputString has no character greater than the keyChar, I am supposed

How do I add a "else" clause to the loop for list "a"? if "inputString" has no character greater than the "keyChar", I am supposed to return a message to the user. Thank you much!

def char(keyChar, inputString): a = min([element for element in inputString.lower() if element > keyChar]); if a==[]: print ("No characters were larger than "+keyChar) #print(a); b= [pos for pos, char in enumerate(inputString) if char == a]; #print(b); print("In "+(inputString)+ ", the smallest character greater than "+(keyChar)+ " is "+a+ " and occurs at position "+str(b));

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!