February 16th, 2013, 01:33 AM
Join Date: Feb 2013
Time spent in forums: 1 h 19 m
Reputation Power: 0
Random Number File Writer / PYTHON
Hello I'm new to python and sort of getting the hang of it...
Heres what I have
#Write a program that writes a series of random numbers to a file.
#Each random number should be in the range of 1 through 100.
#The application should let the user specify how
#many random numbers the file will hold.
Heres what I have:
afile = open("Random.txt", "w" )
for line in afile:
for i in range(input('How many random numbers?: ')):
line = random.randint(0, 100)
print("\nReading the file now." )
afile = open("Random.txt", "r")
Its a few things
1. Its not writing the random numbers in the file the USER is setting.
2. the file once opened cant close
3. when the file is read nothing
Please anyone....any ideas? I seem to always get stuck on execution with python.