Write a function charInWord that takes in two parameters, a char (character) and a word (string). The program will return true if the character is in the word and false if it is not. If word is not a string type, or if char is not a string type, or if the length of char is greater than 1, the function should return None. Your main program should call the function and print char is in word if the function returns true, or char is not in word if the function returns false, using the user-supplied values instead of char and word. The program should print incorrect input provided if the function returns None. Ex: If the input is: a cat the output is: a is in cat Ex: If the input is: a club the output is: a is not in club Ex: If the input is: ab horse the output is:

Answers

Answer 1

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))

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))


Related Questions

Junie is researching Ancient Egypt. She found a website that is full of information and great
images. As she is reading the text, she notices that there are little bits of information that don't
really agree with any of the other research she has done. What should she do?
O Use the website. Most of the information seems correct.
OUse only the information that she needs and ignore the information that doesn't seem right.
O Ask her friend what he thinks about the website.
O Evaluate the site using the CARS checklist to see if the site is valid and reliable.

Answers

Answer: Evaluate the site using the CARS checklist to see if the site is valid and reliable.

Explanation:

A gui allows you to interact with objects on the screen such as icons and buttons true or false

Answers

Answer:

True

Explanation:

Which is a potential disadvantage of emerging technologies? A. increased spread of misinformation due to advanced communication technologies B. inefficient usage of energy due to advanced manufacturing technologies C. only benefiting developed countries rather than developing ones D. slowing down global economic growth

Answers

Answer: I believe it’s D.

Explanation: Less developed countries may not be able to afford the new technology, while more developed ones will be able to do so. Meaning the less developed countries will most likely not change.

Other Questions
Please help!!Using real-life examples, explain one cultural and scientific space innovation of Russia during the twentieth century. Write at least three to four sentences to explain the space technology, the scientific responsible for the innovation, and the impact on Russian society (or the world). Write an equation that represents the line.Use exact numbers. Can someone help Juliette ate 1/3 of a cake, and Brad ate 3/8 of the same cake. What fraction of the cake was eaten? PLEASE HELPLarge expanses of North Africa, Southwest Asia have an average rainfall of 10 inches or less per year. What kind of climate receives less than 10 inches of rain or less? ) Jess has saved dimes ($ 0.10) and quarters ($ 0.25) in their piggy bank. Define the variables and write asystem of equations to determine the number of dimes and quarters if they have 25 coins worth $4.00in total. Then solve the system using the best method for the situation. ayuda plis es para hoy. You are visiting the rainforest, but unfortunately your insect repellent ran out. As a result, at each minute, with probability 0.5, one mosquito lands on your neck, and with probability 0.5, no mosquito lands. If a mosquito lands, it will bite you immediately with probability 0.2, or leave immediately with probability 0.8. a) What is the expected time between successive bites What are the spouses of kings and queens called? Congruent Triangles. Thorough explanation will earn brainiest!! SASASAAASCan't determine What changes do you noticein your body when youexperience stress? can someone help me solve this? How did the end of slavery change the farming system in Texas? Please help its urgent!!! For grimly Plz plz plz plz plz plz plz When Pope Gregory IX rose to power, what domestic animal did he order to exterminate across Europe in the belief that they were used in devils worship and witch craft?15 points going out to the first 2 people. good luck. Also, Friends anyone? Can anyone who speaks Japanese help? PLEEASE! I need to know how to pronounce this. Please type it out in english. I'll pay idc. I'm just soooo desperate! 7 8 8 3 4 8 Rocket League9 12 The protective layer of cells of the outer epidermis is called the Find the diameter of a circle with circumference 44 cm Pass compos, Imparfait, Plusqueparfait ensembleUne soire la Chasse-Galerie Chaque mercredi soir, les tudiants (1) __ (avoir) lhabitude de sortir la Chasse-Galerie qui (2) __ (tre) un bar tudiant qui (3) __ (se situer) sur le campus de luniversit. Ces soirs-l, ce/c (4) __ (tre) toujours une grande fte. Un mercredi soir, Jeremy et ses camarades de classe (5) __ (arriver) trs tard au bar parce quils (6) __ (devoir) tudier beaucoup pour lexamen du lendemain. Ils (7) __ (faire) les derniers devoirs et (8) __ (reviser) toutes les notes que leur professeur leur (9) __ (donner). leur arrive, plus de deux cents tudiants (10) __ (tre) prsents. Certains (11) __ (chanter), dautres (12) __ (prendre) de la bire et (13) __ (bavarder). Il y (14) __ (avoir) une vritable ambiance de fte! Sans perdre une minute, Jeremy (15) __ (commander) quelque chose boire. Ensuite, il (16) __ (sinstaller) dans un coin avec des amis. Soudain, il (17) __ (voir) la jolie jeune fille quil (18) __ (rencontrer) la semaine davant. Il lui (19) __ (parler), et, comme elle (20) le __ (trouver) si gentil, elle (21) __ (sasseoir) avec lui et ils (22) __ (passer) la soire lun ct de lautre bavarder. Des mois plus tard, on (23) __ (apprendre) que ce soir-l, la vie de Jeremy (24) __ (changer) radicalement. Il (25) __ (continuer) de frquenter cette fille qui (26) __ (venir) elle aussi de Toronto et, quelques annes plus tard, ils (27) __ (se marier). Lautre jour, Jeremy (28) __ (me envoyer) un courriel pour mannoncer que leur premier bb, un petit garon, (29) __ (natre) il y a un mois. On peut dire quil (30) __ (sen passer) des belles choses lcole internationale de franais! A vehicle rental company charges $35 to rent a moving van plus $.40 for each mile traveled. Which expression represents the total cost of renting a van and driving d miles? *A. 35 + dB. 35 + 0.40dC. 35 0.40dD. 35d + 0.40