what's wrong with this python code ! please help ! def arr[] = make_list('file_name'): fin = open('file_name') t = [ ] for line in fin: text = line.rstrip('\r\n') number = int(text) t.append(number) it actually shows error in first line "def arr[] = make_list('file_name'):" so please explain .thanks
which programm u r using
python
1)Welcome to Open Study 2) this is a computer science question, please post in that section. you are cuurently in the math group 3) I don't think python likes you using an assignment in the same line as the definition. also, I'm not understanding why you have the variable file_name as a string in the definition; file_name is a variable as far as this program is concerned, and can be assigned to a string or whatever later when you run it. I'm not an expert in python though. perhaps something like def make_list(file_name): fin=open(file_name) t=[] for line in fin: text = line.rstrip('\r\n') number = int(text) t.append(number)
Join our real-time social learning platform and learn together with your friends!