Write a method checkCharacter () which has 2 parameters a string and a specified index (an int) method checkCharacter() checks the character at the specified index of the string parameter and return a string based on the type of character at that location indicating if the character is a letter, digit, white space or unknown character

Respuesta :

The program is an illustration of conditional statements.

Conditional statements are statements whose execution is dependent on the truth value of the condition.

The checkCharacter() method in Python, where comments are used to explain each line is as follows:

#This defines the method

def checkCharacter(myStr,indx):

   #This checks if the character at the index, is a letter

   if myStr[indx].isalpha():

       #If yes, it returns "Letter"

       return "Letter"

   #This checks if the character at the index, is a digit

   elif myStr[indx].isdigit():

       #If yes, it returns "Digit"

       return "Digit"

   #This checks if the character at the index, is a white space

   elif myStr[indx] == " ":

       #If yes, it returns "White Space"

       return "White Space"

   #If all the above conditions are false

   else:

       #It returns "Unknown Character"

       return "Unknown Character"

The string to return depends on the character at the index.

Read more about similar programs at:

https://brainly.com/question/16818003

ACCESS MORE
ACCESS MORE
ACCESS MORE
ACCESS MORE