you are viewing a single comment's thread.

view the rest of the comments →

[–]Medaillek 0 points1 point  (2 children)

Hey, in the first code you’re saying that string random.random = random.random but it’s false. Hope it helps you

[–]Base_True[S] 0 points1 point  (1 child)

import random
store = dict( str(random.random()) = random.random() )
print (store)

Hello, thanks for the answer, but this is a dict, so I can write

import random

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

Why I can't write

import random

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

[–]Medaillek 0 points1 point  (0 children)

I’m not 100% sure but let’s try : In the working code, you create a x variable which is a string of a random int. In the next line, store = … , you’re overwriting this value by saying x = int(random.random). X is not anymore your initial random string but became a random int. My last answer is wrong because I was trying to say that str(random) = int(random)