0
Python string operation
Why ‘17’ * ‘87’ can’t not be multiplied Why did it show error??
6 Respuestas
+ 5
It's because you cannot multiply strings. You have to do it like this:
"17" * 87
+ 1
thank you so much
+ 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.
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"
0
17*87 this code work try it once
- 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)