Skip to content
Advertisement

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

JavaScript

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

JavaScript

Here In your case

JavaScript

will now work

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