rompt the user to enter a string of their choosing. Output the string. Ex: Enter a sentence or phrase: The only thing we have to fear is fear itself. You entered: The only thing we have to fear is fear itself. Complete the get_num_of_characters() function, which returns the number of characters in the user's string. We encourage you to use a for loop in this function. Extend the program by calling the get_num_of_characters() function and then output the returned result.  Extend the program further by implementing the output_without_whitespace() function. output_without_whitespace() outputs the string's characters except for whitespace (spaces, tabs). Note: A tab is '\t'. Call the output_without_whitespace() function in main(

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

6.29 LAB: Warm up: Text analyzer & modifier

Prompt the user to enter a string of their choosing. Output the string.
Ex:

Enter a sentence or phrase: The only thing we have to fear is fear itself. You entered: The only thing we have to fear is fear itself.

Complete the get_num_of_characters() function, which returns the number of characters in the user's string. We encourage you to use a for loop in this function.

Extend the program by calling the get_num_of_characters() function and then output the returned result. 

Extend the program further by implementing the output_without_whitespace() function. output_without_whitespace() outputs the string's characters except for whitespace (spaces, tabs). Note: A tab is '\t'. Call the output_without_whitespace() function in main().

Ex:

Enter a sentence or phrase: The only thing we have to fear is fear itself. You entered: The only thing we have to fear is fear itself. Number of characters: 46 String with no whitespace: Theonlythingwehavetofearisfearitself.

I need help with the whitespace part. Use Python for this, please.

LAB
6.29.1: LAB: Warm up: Text analyzer & modifier
0/6
АCTIVITY
main.py
Load default template...
1 def get_num_of_characters(text):
count = 0
for char in text:
2
3
4
count = count + 1
return count
7 def output_without_whitespace (text):
return text.replace(" ", "")
8
10 text = input("Enter a sentence or phrase:")
11 print("You entered:
12 res = get_num_of_characters(text)
13 print("Number of characters: ",res)
", text)
14
15 r = output_without_whitespace(text)
16 print("String with no whitespace: ",r)
Transcribed Image Text:LAB 6.29.1: LAB: Warm up: Text analyzer & modifier 0/6 АCTIVITY main.py Load default template... 1 def get_num_of_characters(text): count = 0 for char in text: 2 3 4 count = count + 1 return count 7 def output_without_whitespace (text): return text.replace(" ", "") 8 10 text = input("Enter a sentence or phrase:") 11 print("You entered: 12 res = get_num_of_characters(text) 13 print("Number of characters: ",res) ", text) 14 15 r = output_without_whitespace(text) 16 print("String with no whitespace: ",r)
O Only show failing tests
Download this submission
1: Compare output a
0/1
Output differs. See highlights below.
Special character legend
Input
The only thing we have to fear is fear itself.
Your output starts
htence or phrase:You entered: The only thing we have to fear is fear its
with
Enter a sentence or phrase:4
Expected output
starts with
You entered: The only thing we have to fear is fear itself.
2: Unit test a
0/1
Tests that get_num_of_characters() returns 46 for "The only thing we have to fear is fear itself."
Your output
Enter a sentence or phrase:
3: Unit test a
0/1
Tests that get_num_of_characters() returns 44 for "The rain in Spain stays mainly in the plain."
Transcribed Image Text:O Only show failing tests Download this submission 1: Compare output a 0/1 Output differs. See highlights below. Special character legend Input The only thing we have to fear is fear itself. Your output starts htence or phrase:You entered: The only thing we have to fear is fear its with Enter a sentence or phrase:4 Expected output starts with You entered: The only thing we have to fear is fear itself. 2: Unit test a 0/1 Tests that get_num_of_characters() returns 46 for "The only thing we have to fear is fear itself." Your output Enter a sentence or phrase: 3: Unit test a 0/1 Tests that get_num_of_characters() returns 44 for "The rain in Spain stays mainly in the plain."
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY