+ 1

How do make something random?

22nd Mar 2017, 2:30 AM
Joseph Fisher
Joseph Fisher  - avatar
5 odpowiedzi
+ 2
import random print(random.randint(1,5)) that returns a random number between 1 and 5. list=["A", "B", "C"] random.choice(list) that will pull a random element from a list
22nd Mar 2017, 2:33 AM
LordHill
LordHill - avatar
+ 1
Thanks
22nd Mar 2017, 2:34 AM
Joseph Fisher
Joseph Fisher  - avatar
+ 1
no problem. check my codes, I have a bunch of python. steal whatever
22nd Mar 2017, 2:39 AM
LordHill
LordHill - avatar
+ 1
by the way, in my example I named my list "list" .. don't do that. another tip, don't name a file random.py.. screws up random. learned that the hard way
22nd Mar 2017, 2:50 AM
LordHill
LordHill - avatar
0
Check my codes ;)
22nd Mar 2017, 2:05 PM
Gabri