Answer:
The program in Python, is as follows:
def charInWord(chr,word):
if len(chr)>1:
print("None")
elif not(chr.isalpha() and word.isalpha()):
print("None")
else:
if word.find(chr) == -1:
print(chr+" is not in "+word)
else:
print(chr+" is in "+word)
chr = input("Character: ")
word = input("Word: ")
print(charInWord(chr,word))
Step-by-step explanation:
This defines the function
def charInWord(chr,word):
This checks if the length of character is greater than 1
if len(chr)>1:
If yes, it prints None
print("None")
This checks if the character or the word contains invalid character
elif not(chr.isalpha() and word.isalpha()):
If yes, it prints None
print("None")
This is executed for valid parameters
else:
If the character is not present, this is executed
if word.find(chr) == -1:
print(chr+" is not in "+word)
If the character is present, this is executed
else:
print(chr+" is in "+word)
The main begins here
This gets the character
chr = input("Character: ")
This gets the word
word = input("Word: ")
This calls the method and prints the required output
print(charInWord(chr,word))