Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- # list size
- list_size = 10
- # define num of 0 and 1
- zero_count = random.randint(0, 5)
- one_count = list_size - zero_count
- # randomly create 0 and 1
- my_list = [0]*zero_count + [1]*one_count
- random.shuffle(my_list)
- print(my_list)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement