Python Forum
not find the resone it not prints
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
not find the resone it not prints
#1
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.
Reply
#2
Yes i got it https://www.google.com
Reply
#3
(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
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
Reply
#4
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  not finding the resone for the error yukhei 3 1,738 May-22-2020, 03:39 PM
Last Post: deanhystad
  not finding the resone for the error yukhei 3 2,081 May-21-2020, 04:43 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020