Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
For new line I have used "\n" in my code . But it generates error . The code is -
"\n"
value1=100 value2=10.10 value3 ="Hello world" print value1+"\n"+value2+"\n"+value3;
int
float
str
value1 and value2 are not strings. you must convert them, print str(value1)+"\n"+str(value2)+"\n"+value3
value1
value2
print str(value1)+"\n"+str(value2)+"\n"+value3
Add a comment
Best Program with using pep8 format
value1 = 100 value2 = 10.10 value3 = "Hello world" print "Value1 = %s \nValue2 = %s \nValue3 = %s" % (value1, value2, value3)
OUTPUT
Value1 = 100
Value2 = 10.1
Value3 = Hello world
In addition to the other answers here, the simplest change you can do is to use the grouping operator by changing all + to ,
+
,
print value1,"\n",value2,"\n",value3
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
intandfloattypes tostrin order to concatenate them. It's not to do with the newline character