0

Print datatype related

How can integer multiply with string in below code a=8 b=4 c=a/b d=str(c) print(2*d) Output is 2.02.0 How is that possible?

1st Jun 2020, 6:51 PM
Munir Ahmed Yakin
3 ответов
+ 1
That's just how python works, if you multiply a string by a number it will print the string that many times. What were you expecting or trying to have happen?
1st Jun 2020, 6:58 PM
JME
0
I thought like python doesn't add string and no. Same it won't multiply string and int and give a ERROR
1st Jun 2020, 7:00 PM
Munir Ahmed Yakin
0
"Hi" * 3 = "Hi" + "Hi" + "Hi" = "HiHiHi"
1st Jun 2020, 9:37 PM
Leonid Selivanov
Leonid Selivanov - avatar