+ 8
How to permanently store any random generated value?
I want to store it in somewhere so that It will return the previous random value(that I've stored) not the newly random value. Also, using any database like sqllite it will always generate a new value and store it. Same with Pickel module Any way for doing so?
12 Respuestas
+ 4
𝙍𝙞𝙨𝙝𝙖𝙗𝙝
You can run this code in an IDE where there already exists file 'filename.txt'
And it will keep on adding text as you run it
https://code.sololearn.com/cZ66iKNMr7Nm/?ref=app
+ 7
Nope, it will always give the new value that it will generate but what I want is:
Whatever it generate at any time that also it stores again and shows the previous value
Namit Jain
Like:
https://code.sololearn.com/cY830SXsz958/?ref=app
Whatever value it will generate firstly I want to store it and print it then
+ 6
Lothar
I got the answer.
Now, my turn to try.
If you want to know where I would use it so,I want to use it in a code that will generate random numbers at running it different times, I'll need them when running the code second time and it will
print it the number generated firstly.
Printing it is enough for me.
I hope I was clear!
+ 5
Namit Jain
I think I'm unable to explain you.
Will you please give me an example so that I can tell you??
+ 5
Namit Jain
No output 😶
+ 5
what are you planning to do with the "older / previous" values? Please try to describe it without caring about possible solution. When will you need them? in the same session? on a different day? And how should they be used or processed?
+ 5
Namit Jain
I've uploaded the file(an empty file)and copied it's link too but it's saying "No such file or directory"
+ 3
generate the random variable, write it to a text file and save it. then when you want to access the random number, read the text file?
+ 2
Storing them in the files will help you!
+ 2
𝙍𝙞𝙨𝙝𝙖𝙗𝙝 read the complete answer 😐
+ 2
𝙍𝙞𝙨𝙝𝙖𝙗𝙝 ya same problem faced by me too!
We will have to import some library that can accept online links! Try searching it on google! Something like urllib, http etc libraries should be used ig
+ 1
𝙍𝙞𝙨𝙝𝙖𝙗𝙝 Use the append mode