인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

Kyu-Chan Lee's profile image
Kyu-Chan Lee

asked

Introduction to Python for Programming and Data Science

- How to submit assignments: File handling

get_number_of_target_words에서요…

Written on

·

140

0

결과 값이 달라서요 질문 드립니다

def get_number_of_target_words(filename, target_words):

contents = get_file_contents(filename)

contents_list = contents.upper().split()

result = 0

for word in contents_list:

if target_words.upper() in word:

result += 1

이거랑

print(contents.lower().count(target_words.lower()))

'Hi'를 target word로 할 때 값이 각각 3928과 3938로 다른데, 그 이유가 뭔가요...?

bigdatapython

Answer 1

0

TeamLab님의 프로필 이미지
TeamLab
Instructor

split을 했기 때문으로 보입니다. Hi가 붙어있는 경우와 떨어져있는 경우를 카운트했는가 차이입니다.

Kyu-Chan Lee's profile image
Kyu-Chan Lee

asked

Ask a question