Dec-10-2019, 02:23 AM
Use
Here some fixes in your code,use 4-space indentation,a function should take argument,
and not getting the value for global namespace over.
Use
str(z) + "\n"
.Here some fixes in your code,use 4-space indentation,a function should take argument,
and not getting the value for global namespace over.
Use
r
raw string in Path,you are using Python 2 as C:\Users
will give SyntaxError in Python 3.r"C:\Users\Kingsley\Projects\X\wite.csv"Use Python 3,not Python 2 as is dead in under a month.
def joinFunction(z1, s): x = 5 y = 6 z = x + y z1.write(str(z) + "\n" + s) z1.close() z1 = open("wite.csv", "w") v = "python is " x = "pretty awesome " y = "and amazing" s = v + x + y joinFunction(z1, s)
Output:11
python is pretty awesome and amazing
With f-string can just put in \n
.with open('out.txt', 'w') as f: x = 5 y = 6 z = x + y c = x ** y f.write(f'Result is {z}\nResult is {c}')
Output:Result is 11
Result is 15625