About strings | Sololearn: Learn to code for FREE!

0

About strings

how multiplication works in between two strings.

11/20/2016 10:00:48 AM

Sree Latha

5 Answers

New Answer

+5

The strings can't be multiplicated each other. But you can repeat a string with * (integer)

+2

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)