why wont it randomize? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

why wont it randomize?

import random lst=["A", "B"] random.choice(lst) A=print("......") B=print("#....")

18th Nov 2017, 4:42 PM
Joseph Fisher
Joseph Fisher  - avatar
1 Answer
0
Right now you're just assigning A and B to nothing because you're using the print() function (always returns None). If you wanted A and B to be random, you could do: A = random.choice(lst) B = random.choice(lst) random.choice returns (basically what the function equals in a way) a random choice from the list, so by assigning the variables to it, you get a random element
17th Mar 2022, 5:28 AM
Sketch Maniac
Sketch Maniac - avatar