The pythonic approach to do this is
#!/Python34/python
num_list = []
with open('temperature.text', 'r') as fh:
for line in fh:
num_list.append(int(line))
You don't have to utilize close here in light of the fact that the 'with' statement handles that consequently.
On the off chance that you are OK with List comprehensions - this is another strategy :
#!/Python34/python
with open('temperature.text', 'r') as fh:
num_list = [int(line) for line in fh]
In the two cases 'temperature.text' should be in your present directry.
Want to become a expert in Python? Join the python course fast!
For more details, do check out the below video tutorial...