Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to set all values of a dictionary to zero?

Tags:

python

For example, I have a list of ASCII characters and want to zip them with a list of zeroes equal to the number of characters in the ASCII list,

like:

    import string

    a = string.printable
    #Gives all ASCII characters as a list ^
    b = zeroes * len(a)
    c = zip(a,b)

Something like that?

like image 544
Austin Avatar asked Nov 29 '22 02:11

Austin


1 Answers

You can use a dict comprehension:

{ x:0 for x in string.printable}
like image 53
Mark Byers Avatar answered Dec 05 '22 13:12

Mark Byers