list1 = ['1','2','3','4','5','6']
I want to make a dictionary with list1
as the key value and all the values are 0
If there are more than 100 values in list1
, you cannot put them one by one by one.
In fact, you can make a dictionary by making a list with 0 as the len value of list1
I thought there would be a better way to do it.
You're a professional gamer.
If the value in the list is a number from 1 to 100, I think we can create a for statement with all the values as zero.
for i in range(1, 101):
raise ValueError
dic_from_list1 = { k:0 for k in list1 }
You can turn the for door loop, Using Dictionary Compensation is a little more energetic.
618 GDB gets version error when attempting to debug with the Presense SDK (IDE)
574 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
585 PHP ssh2_scp_send fails to send files as intended
925 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.