0

Python string operation

Why ‘17’ * ‘87’ can’t not be multiplied Why did it show error??

1st Jul 2019, 6:06 AM
Aru
6 Antworten
+ 5
It's because you cannot multiply strings. You have to do it like this: "17" * 87
1st Jul 2019, 6:11 AM
Airree
Airree - avatar
+ 1
thank you so much
1st Jul 2019, 6:36 AM
Aru
+ 1
When ever you put text between a quote pair " " or ' ', you have declared a string, a text object. '17' and '87' are actually strings, and don't share same behavior than 17 and 87, which would be integers. Because there is no defined behavior for string * string, Python assumes it to be safest to just raise an error and terminate the program.
1st Jul 2019, 6:36 AM
Seb TheS
Seb TheS - avatar
0
Because you can't multiply a string by another string in python. Can you imagine to multiple a text by another text yourself? 😵 If you want to get numeric answer you should use 17* 87 instead of "17"*"87"
1st Jul 2019, 6:11 AM
ΛM!N
ΛM!N - avatar
0
17*87 this code work try it once
25th Jul 2019, 8:46 AM
jessy polinati
- 1
You can't multiply string with a number e.g print ( " 43" * 3), error message will appear. So try : print( 46* 56) ( this figures are just for example)
5th Aug 2019, 10:29 AM
Gberekpee Lucky
Gberekpee  Lucky - avatar