I have a boolean list consist of True and False as follows. I want to know how to change all the values in a list to True or False at once.
my_list = [ False, True, False ]
print(my_list)
my_list[:] = True
The last line throws an exception error, which is not what I expected.
my_list = [False, True, False]
my_list[:] = [True] * len(my_list)
print(my_list)