Skip to content
Advertisement

Whenever i use random.choice in Python, i get an error. The error is in the ‘body’ page

playsound.playsound(random.choice(beatboxes))

AttributeError: ‘builtin_function_or_method’ object has no attribute ‘choice’

Process finished with exit code 1

there is an alternative to the bultin random module?

Thanks

Advertisement

Answer

To use random with a choice like you write in code you need to import

import random

Here In your case

from random import * 

will now work

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement