0
About strings
how multiplication works in between two strings.
5 Réponses
+ 8
The strings can't be multiplicated each other. But you can repeat a string with * (integer)
+ 3
If the strings represent numbers, you can convert them to numbers, multiply the numbers and if needed, convert the result back to string
0
Alain, you're wrong. Your example doesn't work, because you multiply None that print returns by 10 and it gives an error :
>>> print ("@") * 10
@
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
print ("@") * 10
TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'
Here is the correct example:
print('coding...'*5)
coding...coding...coding...coding...coding...
0
For Sree Latha.
In this case, "spam" and "eggs" are considered variables. print(spam*eggs)=4*5=20
- 2
spam=2
eggs=3
del spam
spam=4
eggs=5
print(spam*eggs)