0

My code is as follows and enclosed is a link to the screenshot of the error. It wants me to test for number of characters in a sentence

def get_num_of_characters(inputStr):
    return len(inputStr) 

def output_without_whitespace(inputStr):
    output=''
    for i in range(0,len(inputStr)):
        if(inputStr[i]==' ') or (inputStr[i]=='\t'):
    exit 
    else: 
        output+=inputStr[i]
return output

# if __name__=="__main__":

inputStr=input("Enter a sentence or phrase: \n")
print("You entered:",inputStr)
print("\nNumber of characters:",get_num_of_characters(inputStr))
print("String with no whitespace:",output_without_whitespace(inputStr))

Enter a sentence or phrase: Traceback (most recent call last): File "zyLabsUnitTestRunner.py", line 4, in from zyLabsUnitTest import test_passed File "/home/runner/local/submission/unit_test_student_code/zyLabsUnitTest.py", line 1, in from main import get_num_of_characters File "/home/runner/local/submission/unit_test_student_code/main.py", line 15, in inputStr=input("Enter a sentence or phrase: \n") EOFError: EOF when reading a line

John
  • 11
  • 1
  • 1
  • 6

1 Answers1

0

This works for me using python-3.x. In 2.x, I changed:

inputStr=input("Enter a sentence or phrase: \n")

To:

inputStr=raw_input("Enter a sentence or phrase: \n")

See this answer for a more in-depth explanation between the two.

Kevin
  • 352
  • 2
  • 4
  • 13