enter key 입력시 종료하는 프로그램 ValueError: could not convert string to float

조회수 1146회
    total=0

    def readAndTotal():

       global total

       num=float(input('Enter a number'))

       if num !='':
          total+=num
          return readAndTotal()


       else:
          return total


    total = readAndTotal()
    print("The total of all those values is", total)

엔터키를 누르기 전입력값들의 합을 출력하는 프로그램입니다. 이 코드를 작동시켜보면 str값을 float값으로 convert할 수 없다고 나옵니다. 어느부분이 문제인건가요?

ValueError: could not convert string to float:

1 답변

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)