看不懂为什么报错,复制粘贴下来的

编程题:请设计一个课程类,包含课 程编号、课程名称、任课教师、上课地 点等属性,把上课地点变量设为私有 的,增加构造方法和显示课程信息的方法。

class Course:

def __init__(self,cno,cname,cteacher,cloc):

self.cno = cno

self.cname = cname

self.cteacher = cteacher

self.__cloc = cloc

 

>>> def show(self):

print("课程编号:",self.cno)

print("课程名称:",self.cname)

print("任课教师:",self.cteacher)

print("上课地点:",self.__cloc)

 

>>> c = Course('1001','Python程序设计','王芳','教学楼1201')

>>> c.show()

Traceback (most recent call last):
  File "<pyshell#14>", line 1, in <module>
    c.show()
AttributeError: 'Course' object has no attribute 'show'

Show是不是写在类外面了,讲道理应该是

你的show是不是写在类