#클래스
class Polynomial :
def __init__(self) :
self.coef= []
def degree(self) :
return len(self.coef) - 1
def display(self, msg = "f(x) = ") :
print(" ", msg, end='')
deg = self.degree()
for n in range(deg, 0, -1) :
print("%5.1f x^%d + " % (self.coef[n], n), end ='')
print("%4.1f"%self.coef[0])
#함수
def read_poly():
instr = input("최고차항부터 차수를 순서대로 입력하시오: ")
strlist = instr.split()
p = Polynomial()
for coef in strlist :
val = float(coef)
p.coef.insert(0, val)
#테스트
a = read_poly()
a.display("A(x) = ")
-----------------------------
내가 문제 되는 것 같은 부분만 긁어 왔어
'NoneType' object has no attribute 'display'
라고 컴파일 오류가 나는데 구글링 해봐도 값이 입력되지 않아 생기는 오류라는데
코드를 계속 읽어봐도 문제되는 부분이 안보여 ㅠㅠ 어디가 문제일까
read_poly() 함수에서 return을 안해줬네요. 해결했습니다...........
아니 에러 문구가 영어라고 읽을 생각 조차 안하는거냐 ??? read_poly() return 에 display 가 없다잖아 보니깐 리턴을 안하네
line 51, in a.display("A(x) = ") AttributeError: 'NoneType' object has no attribute 'display'
저는.. 요렇게밖에 안떠서.. display 정의한분에 매개변수에 문제가 있는줄 알았서요.. 제성합니당..