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

Inflearn Community Q&A

banko's profile image
banko

asked

Introduction to Python for Programming and Data Science

- Code Assignment: File IO

get_number_of_lines

Written on

·

120

0

조금 특이하게 짜긴 한 것 같은데..

def get_number_of_lines(filename):
    with open(filename, "rb") as f:
        count = 0
        while str(f.readline()):
            count += 1
            print(count)

    return count-1


코드를 위와 같이 짰습니다! 파이썬 쉘에서는 정상적으로 작동 하는데 문제는 submit 했을 때

숫자가 무한히 커지면서 계속 출력되네요... 왜 그러는 걸까요?

bigdatapython

Answer

This question is waiting for answers
Be the first to answer!
banko's profile image
banko

asked

Ask a question