Python Forum

Full Version: not find the resone it not prints
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hi i'm lerning classs, trying to rool a dice
this is what i wirted
from random import randint

class die():
	def __init__(self,sides):
		self.sides = sides

	def rool_die(self):
		randint(1,self.sides)


dice = die(6)
dice.rool_die()

dice2 = die(10)
dice2.rool_die()

dice3 = die(20)
dice3.rool_die()
but the out put get nothing , im stoke Wall with it help plasea.
Dice: Make a class Die with one attribute called sides, which has a default value of 6. Write a method called roll_die() that prints a random number between 1 and the number of sides the die has. Make a 6-sided die and roll it 10 times.
Make a 10-sided die and a 20-sided die. Roll each die 10 times.
(May-22-2020, 12:46 PM)amazingadmin Wrote: [ -> ]Yes i got it https://www.google.com

Is that site supposed to be helpful for the person who has posted the thread? It is only a google homepage
The default return value for functions and methods is None. To return something else the function or method must include a "return x" statement where "x" is the thing you want to return. Your "roll_die" method (it should be called "roll") does not specify a return value, so it returns None.