I am trying to go to next line after a match in python. I have a file:
ratio of lattice parameters b/a c/a
1.000000000000 1.000000000000
lattice parameters a b c [a.u.]
9.448629942895 9.448629942895 9.448629942895
So, when I have "lattice parameters" at the beginning of line, I will read the next line (e.g. 9.448629942895 9.448629942895 9.448629942895)
I am doing:
#!/usr/bin/python3
import sys
inpf = str(sys.argv[1])
print (inpf)
with open(inpf, "r") as ifile:
for line in ifile:
if line.startswith("lattice parameters"):
print(line.strip())
next(ifile)
return next(ifile)
as is in the accepted answer here. But, in my case, it is giving error:
python xband.py AlSi2S2.sys
File "xband.py", line 11
return next(ifile)
SyntaxError: 'return' outside function
What I am doing wrong here?
NB: I want to go to and read next line. I have no special fascination on "return"
I am using Python 3.4.2
def getLine(...):and it's gonna be fine.