I need to keep calling sync for each line in file.txt until the function returns non-zero(that is when it fails). Currently I plan to do the following.
for line in file("file.txt"):
change=int(line)
cp_success=sync(change) #check the return value of function sync
if cp_success!=0 :
break #Try using a break statement
Is there a better way or one-liner?
Well, almost in one line (if you allow me to import the itertools module):
Example w/o file:
But you really should not obscure things, so why not just: