I know this is something extremely easy to do but i don't master the python syntax at the moment. I've read the documentation and I've been searching on the 'net for information but nothing that I've found seems to be what I'm looking for. Probably the reason is the fact that what i am trying to do is something that any programmer knows but since i only know C/C++, python is somewhat different to me. I really like it but i need to get used to (and learn more about) the way that you specify (or actually don't specify) the data types you are working with.
This is what i managed to write (I've also read part of the "Starting Python" thread here):
def getlist(): nrlist= while True: aux=data.readline() if aux==EOF: return list try: n=float(aux) nrlist.append(n) except ValueError: print "Introdu date numerice!" #Its in romanian.. meaning "Enter numeric data!." data=open(data,"r") list= list=getlist() print list
The error I'm getting is:
Traceback (most recent call last): File "[not relevant]\workspace\primul\src\primul.py", line 21, in <module> data=open(data,"r") NameError: name 'data' is not defined
I apologize if I am wasting your time with such an easy question but I've figured that I'll win some time if I get an exact answer from you then searching on and on and trying various ways of writing the code.
Thank you for your help!