Python rookie, could you tell me what the following error is all about? thank you very much.

from random import randint

class Die ():

def _init_(self,num_sides=6):
    self.num_sides=num_sides
def roll(self):
    return randint(1,self.num_sides)

die=Die ()
results= []
for roll_num in range (1100):

result=die.roll()
results.append(result)

print (results)

error report:
raceback (most recent call last):
File "D:/python_work/die_visual.py", line 11, in < module >

result=die.roll()

File "D:/python_work/die_visual.py", line 6, in roll

return randint(1,self.num_sides)

AttributeError: "Die" object has no attribute" num_sides"

Process finished with exit code 1

Mar.04,2021

_ init__ not _ init_ two underscores


init are mistakes easily made by two underlined novices


_ init__ () method is a special method, which is called the constructor or initialization method of the class. The method


is called when an instance of this class is created. I have the same problem because I wrote _ _ init__ as _ _ int__


I wrote init as int error!

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4241b-436ca.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4241b-436ca.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?