0

Why "12"*2 Gives output 1212 ? Why not 24?

😵

26th Jul 2019, 6:51 PM
Shubham Minhas
Shubham Minhas - avatar
3 odpowiedzi
+ 2
"12" is a string, and when multiplying a string, it is repeated as many times as the multiplier is. Example: print ("a" * 3) Output: aaa. https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2427/
26th Jul 2019, 7:19 PM
Solo
Solo - avatar
+ 1
The speech marks("") turn 12 into a string. So 12 * 2 is 24, but "12" is a string so it doubles the string, which is 1212. E.g: Print("12"*2) == 1212 Print(12*2) == 24
26th Jul 2019, 7:19 PM
coffeecup
coffeecup - avatar
0
Oki Thank You 🌹
27th Jul 2019, 2:10 AM
Shubham Minhas
Shubham Minhas - avatar