Answered step by step
Verified Expert Solution
Question
1 Approved Answer
string python help , sorry for the first and last line, thanks oding PTobierm44.2S (EXLerialreseuCe) (3.0 points possible) SubmitRun Grades Re L rite a Tunction
string python help , sorry for the first and last line, thanks
oding PTobierm44.2S (EXLerialreseuCe) (3.0 points possible) SubmitRun Grades Re L rite a Tunction callea string type wnicn accepts one 2 #string argument and determines what type of string it is Console output will be displayed here 3 # -If the string is empty, return "empty" 4# If the string is a single character, return "character". 5#-If the string represents a single word, return "word". 6# The string is a single word if it has no spaces 7# -If the string is a whole sentence, return "sentence". 8 # The string is a sentence if it contains spaces, but 9 # at most one period 10 # -If the string is a paragraph, return "paragraph". The 11 # string is a paragraph if it contains both spaces and 12 # multiple periods (we won't worry about other punctuation marks) 14 # -If the string is multiple paragraphs, return "page". 15 # The string isaparagraph if it contains any new 16 # characters (" ") 17 #Hint: think carefully about what order you should check 18#these conditions in 19#Hint 2: remember, there exists a count() method that 20 #counts the number of times a string appearsin another 21#string. For example, "blah blah blah". count("blah") 22#would return 3. 23 #Ilrite your function here ; 24#Below are some lines of code that will test your function. 25 #You can change the value of the variable(s) to test your 26#function with different inputs 27#If your function works correctly, this will originally 28 #print: 29 #empty 30#character 31 #word 32 sentence 33 paragraph 34. #page 35 print (string_type()) 36 print(string_type("!")) 37 print (string_type("CS1301.")) 38 print (string_type("This is too many cases!")) 39 print(string-type("There's way too many ostriches. Why are there so many ostriches. The brochure said 6 there'd only be a few ostriches.")) 40 print (string_type("Paragraphs need to have multiple sentences. It's true. However, two is enough. Yes, tur, ?_ntenreE ran malee A nArA@r. AnhStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started