Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions