In the code that I'm writing, I have a nested dictionary which contains a key that has a value of random.randint(0,100)
. Below this code is a while loop that contains functions which need the items from the dictionary.
When the while loop runs again, the random.randint(0,100)
outputs the same value. How do I make it so the random value is different? I tried making a new .py file and placing the random.randint(a,b)
under variables in a While true
loop, but the code in the main file never starts. I couldn't put the dictionary inside of the while loop or after it ended because then the code wouldn't work.
For reference, this is what the code looks like (making a summary of it because the original code is too long to paste):
A = {'Key1': {'Key A1': 1, 'Key B1': 5, 'Random': random.randint(0,100)},
'Key2': {'Key A2': 4, 'Key B2': 7, 'Random': random.randint(5,100)}
'Key3': {'Key A3': 5, 'Key B3': 13, 'Random': random.randint(5,90)}}
while I > 5:
def func(a,b):
Rand_Value = A['Key1']['Random']
print(f'The value for this is {Rand_Value}')
func(10,5)
I'm new to coding, my apologies if the question is not as good as it could be.
Aucun commentaire:
Enregistrer un commentaire