Answered You can hire a professional tutor to get the answer.
(1) Prompt the user to enter a string of their choosing. Output the string. (1 pt) Ex: Enter a sentence or phrase: The only thing we have to fear is...
(1) Prompt the user to enter a string of their choosing. Output the string. (1 pt)
Ex:
phrase: The only thing we have to fear fear itself.You entered: The only thing we have to fear fear itself.(2) 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. (2 pts)
(3) Extend the program by calling the get_num_of_characters() function and then output the returned result. (1 pt)
(4) 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(). (2 pts)
Ex:
phrase: The only thing we have to fear fear itself.You entered: The only thing we have to fear fear itself.Number characters: String with whitespace: Theonlythingwehavetofearisfearitself.----------------------------------------------------------
I have come up with this solution...
def get_num_of_characters(inputStr):
count = 0
for i in range(0,len(inputStr)):
count = count + 1
return count
def output_without_whitespace(inputStr):
statement2 = ''
for i in range(0,len(inputStr)):
if(inputStr[i] == ' '):
statement2 = statement2
else:
statement2 = statement2 + inputStr[i]
return statement2
inputStr = input('Enter a sentence or phrase: ')
print()
print('You entered:', inputStr)
num = get_num_of_characters(inputStr)
print()
print('Number of characters:', num)
print('String with no whitespace:',output_without_whitespace(inputStr))
but I am getting these errors...
returns this output...