หากระทู้ลงไม่ได้ฝากถามกระทู้นี้ต่อแทนน่ะครับ
อ.พงศกรครับ ผมกำลังหัดเรียนเขียนโปรแกรม หารายได้พิเศษนี่เป็นแบบฝึกหัดข้อรองสุดท้ายของผม
ขอคำชี้แนะในการเขียน Python ครับ
class saisin:
def __init__(self,P=0,Q=0):
self.P = P
self.Q = Q
def nup(self,other):
if ((self.P > other.P) and (self.Q < other.Q)):
print '1'
elif((self.P < other.P) and (self.Q > other.Q )):
print '1'
else:
print 'miss'
def getPQ(self):
print self.P, self.Q
def main():
a = saisin(1,2)
b = saisin(2,1)
list = []
list.append(a)
list.append(b)
for i in list:
print i.getPQ()
main()
ผลลัพธ์
1 2
None
2 1
None
อ.ครับ ทำไมมี None ติดมาด้วย?
ผมจะแก้ไขได้อย่างไรและจะมีผลต่อหน่วยความจำที่ไหนบ้างครับ?