Edit with IDLE pull down menu

MRAB python at mrabarnett.plus.com
Sat Jul 21 21:31:25 EDT 2018


On 2018-07-22 00:44, no at none.invalid wrote:
> On Sat, 21 Jul 2018 14:34:15 -0700 (PDT), Rick Johnson
> <rantingrickjohnson at gmail.com> wrote:
> 
> This is really the code I keep copying.
> 
> import random
> from random import randint
> a = [5, 10, 15, 20, 25, 30, 35, 40]
> b = ["Rock","Paper","Scissors","Lizard ","Spock"]
> 
> 
> I am lazy and don't type well, so I leave out some details when
> posting.
> 
> I don't know why the program I needed randint for didn't work with
> just import random, but I moved on without lingering on it.
> 
When you import 'random', that name refers to the module itself. You can 
refer to 'randint', which is defined in that module, by writing 
"random.randint".

Alternatively, as you've done, you can import 'randint' directly from 
the 'random' module.



More information about the Python-list mailing list