jeudi 4 juin 2020

2 questions. Why isn't my replace function working, and how would I make my variable a different random answer every time?

Here is my code:

import random
a=random.randint(0,1)
l=[a,a,a,a,a,a,a]
print(l.replace(',','||||'))

I am trying to make a be chosen as 0 or 1 randomly multiple times in the list and I want the numbers in the list to be divided with '||||'. (example: 0||||1||||1||||0||||1||||1||||1) I am bad at programming because I am mostly new to it, so any help would be greatly appreciated.




Aucun commentaire:

Enregistrer un commentaire