Ask coding questions

← Back to all posts
Random Dose Not Work
FounderRoomyfoo (0)

Keeps On Saying That Random Is Not A thing

Shows The Error

Any Help Is Welcomed

Answered by Coder100 (18930) [earned 5 cycles]
View Answer
Coder100 (18930)

You forgot to import random, it isn't there by default. Here is the correct code:

import random
chest = ['None', 'None', 'Common Chest']
chestP = random.choice(chest)

for good practice, make your variables lowercase.

xfinnbar (149)

To use random, you need to import it just like any other package. Add import random to the top of your file.