Is it possible without loops initialize all list values to some bool? For example I want to have a list of N elements all False.
Is it possible without loops initialize all list values to some bool? For example
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can do it like this: –
NOTE: –
Note that, you should never do this with a
listofmutable typeswith same value, else you will see surprising behaviour like the one in below example: –As you can see, changes you made in one inner list, is reflected in all of them.