0

Help interpreting output of this code!

How did we get to this output? Any help is very much appreciated! Input: a = 1 B = a + 1 print(B, end= “”) print(B,a,sep= “0”) Output: 2201

23rd Apr 2018, 12:20 PM
stephanie
stephanie - avatar
4 odpowiedzi
+ 2
exactly. end="" skips next line and the next print function remains on the same line.
23rd Apr 2018, 12:51 PM
LordHill
LordHill - avatar
+ 4
first it prints B which is 2 because A is 1 and A+1 is 2.. Then end="" introduces a string, so instead of adding B+B which is 4, it adds "B" + "B" which is "22" as a string Then it adds a to it which is 1, and separates them with a "0"
23rd Apr 2018, 12:26 PM
LordHill
LordHill - avatar
+ 1
Thanks! But so does the end=“” get rid of the new line after the first print function as to concatenate it with the output of the second print function?
23rd Apr 2018, 12:50 PM
stephanie
stephanie - avatar
+ 1
You’re the best! Thank you so much
23rd Apr 2018, 12:52 PM
stephanie
stephanie - avatar