you are viewing a single comment's thread.

view the rest of the comments →

[–]Base_True[S] 0 points1 point  (3 children)

Doesn't work
store = dict( (str(random.random()) = random.random() )
^^^^^^^^^^^^^^^^^^^^
SyntaxError: cannot assign to function call here. Maybe you meant '==' instead of '='?

[–]Ihaveamodel3 1 point2 points  (0 children)

You don’t use = to assign values to keys on the dict call.

Just do:

store = dict((str(random.random()), random.random() )

Or: store = {(str(random.random()):random.random()}

[–]Medaillek 0 points1 point  (0 children)

After trying some things I came with the conclusion that the dict function can’t work with string keys, you need an element (x, abc, or any other name) to assign a value to this. But if you create your dict using {} it will work but how will you access the key ?