#python #anaconda #jupyter-notebook #visual-code #html #css #javascript #http

제목Step _ 07 실습에서 None 없애기2021-09-26 02:01
작성자

def calcCharacterFromString(usersentence,userword) :

    if (usersentence.count(userword) > 0) :

        print(usersentence.count(userword)," words in sentence.")

    else :

        return "Error . There is no word in sentence."

    

inputsentence = input("Enter the sentence that you want to test. ")

inputword = input("Enter the word that you want to count. ")


print(calcCharacterFromString(inputsentence,inputword))


이렇게 출력했을때 문장안에 있는 단어로 이제 if구문의 조건에 맞게 값을 입력하면 

2 words in sentence

None 

이런식으로 None이 떠요 제가 그래서 실험적으로 맨 아래에 있는 print 구문을 없애고 

(calcCharacterFromString(inputsentence,inputword) 이것만 입력을 했는데 None이 안뜨더라고요 

어떻게 해서 이런 상황이 발생한건지 모르겠어요 


댓글
이전[re]함수 실행 관련 질문입니다2021-09-27
다음[re]Step _ 07 실습에서 None 없애기2021-09-26