y the output for the third one is {a+25}{a+25}? y not 5050 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

y the output for the third one is {a+25}{a+25}? y not 5050

a=25 print(a+25) print("{a+25}"*2)

13th Aug 2019, 9:16 AM
Noice
Noice - avatar
3 Answers
+ 2
(python) when you multiply a String in python python just extends the String as many times with it's self.
13th Aug 2019, 9:19 AM
Anton Böhler
Anton Böhler - avatar
+ 2
if you write: a = 25 print(str(a+25)*2) then the output will be "5050"
13th Aug 2019, 9:21 AM
Anton Böhler
Anton Böhler - avatar
+ 2
You might be searching for the format method. "{a+25}".format(...)
13th Aug 2019, 9:30 AM
Seb TheS
Seb TheS - avatar