Try using join:
print "\n"+'|'.join([id,var1,var2,var3,var4])
or if the variables are no longer strings:
print "\n"+'|'.join(map(str,[id,var1,var2,var3,var4]))
The advantage of this approach is that you do not need to create a long formatted string, and it practically does not change for an arbitrary number of variables.
source
share