DEV Community

Discussion on: 10 must-know patterns for writing clean code with Python🐍

Collapse
 
mhe931 profile image
mhe931

Thank you so much for your post. It helps a lot.

p.s: dices have 6 sides I think!!

import random

# Not recommended
def roll_dice():
    return random.randint(0, 4)  # what is 4 supposed to represent?

# Recommended
DICE_SIDES = 4

def roll_dice():
    return random.randint(0, DICE_SIDES)
Enter fullscreen mode Exit fullscreen mode
Collapse
 
drystanfuror profile image
Drystan-Furor

Ever played ttrpg’s?
Dices can have
4, 6, 8, 10, 12, 20, and 100 sides.
Polyhedral dice sets. So to me it did make sense.

Collapse
 
dangermanva profile image
Dan

“Dices” is not a word. Dice is already plural, referring to more than one cube. Die is the word to represent one cube.

Btw Good article, the point was well made.