How do I change the output format of a print statement in python?
1 I wrote a code like below A = print("apple") And, I want to change the data type of A to string, so I wrote the following code. A = str(print"apple") type(A) But, the answer was "None". In this What should I do in this situation? Actually what I'm doing right now is to write something like the output to a text file. openFp = open("solution.txt","w") p2 = str(print("I_B : ",I_B)) openFp.writelines(p2+"n") openFp.close() Entering this code will always result in 'None'. python string share | improve this question asked Nov 12 '18 at 7:42 JAE_RYONG JAE_RYONG 26 4 2 Print function does not return values, Instead it write the value into the stdout (by default). Why don't you store the string directly into a variable? – Abdul Niyas P M Nov 12 '18 at 7:46 1 What exactly are you trying to accomplish? I think you have misundersto