Convert to str(z) work. And pick up f-string formatting. Thanks! A follow-up then.
I call the joinfunction twice in the code below. The results seem to be written to the same line in the file. i tried putting "\n" at the end of:
z1.write(str(z)),"\n"
but it still seems to write to the same line instead of the next line. Any ideas
I call the joinfunction twice in the code below. The results seem to be written to the same line in the file. i tried putting "\n" at the end of:
z1.write(str(z)),"\n"
but it still seems to write to the same line instead of the next line. Any ideas
#creating and using a function z1 = open("<path>\file.csv", "w") #global variable 01 set, file create/open v = "python is " #global variable 02 set x = "pretty awesome " #global variable 03 set y = "and amazing" #global variable 04 set print(v + x + y), "\n" def joinFunction(): #defining a function called "joinFunction" x = 5 #joinFunction has a variable local to it called x. x is equal to a y = 6 #joinFunction has a variable local to it called y. y is equal to b z = x + y #local variable z is the value of 5 + 6 z1.write(z)#>>>>problem code here. i can't write integer to file. Not sure why? i think it breaks the joinfunction too. z1.close() joinFunction() print(v + x + y) #prints the combination of the global variables defined above #joinFunction()