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

제목오늘자 퀴즈 2번째 문제 질문2019-11-07 15:09
작성자
첨부파일1.PNG (21.8KB)2.PNG (14KB)

2번째꺼 에러 왜 났는지 모르겠어요ㅠㅠㅠ 누가 설명좀 해주세요ㅠ

Q1.

def getDictionary(x):

    file=open(x,'r')

    Dict={}

    for line in file:

        a=line.split()

        Dict[a[0]]=int(a[1])

        

    return(Dict)

    file.close()

Q2.

def getMaxScore(x):

    x=getDictionary(x)

    y=max(x)

    s=x['y']

    s=int(s)

    return (y,s)

# 아래는 테스트용 코드이며 삭제해도 무방함


x = getDictionary("score.txt")

print(x)

(student,score) = getMaxScore(x)

print(student,score)


TypeError Traceback (most recent call last) <ipython-input-88-992a1f51f3e5> in <module> 3 x = getDictionary("score.txt") 4 print(x) ----> 5 (student,score) = getMaxScore(x) 6 print(student,score) <ipython-input-87-8bb7ac92a02a> in getMaxScore(x) 1 def getMaxScore(x): ----> 2 x=getDictionary(x) 3 y=max(x) 4 s=x['y'] 5 s=int(s) <ipython-input-74-07d9266f7af4> in getDictionary(x) 1 def getDictionary(x): ----> 2 file=open(x,'r') 3 Dict={} 4 for line in file: 5 a=line.split() TypeError: expected str, bytes or os.PathLike object, not dict

댓글