Home > front end >  I have an error "TypeError: can't multiply sequence by non-int of type 'str'&quo
I have an error "TypeError: can't multiply sequence by non-int of type 'str'&quo

Time:08-24

Throwing an error "TypeError: can't multiply sequence by non-int of type 'str'"

text1 = "Hello"
text2 = "World"
result = text1 * text2
print(result)

Error message:

result = text1 * text2
TypeError: can't multiply sequence by non-int of type 'str'

CodePudding user response:

Sorry this multiplication is not possible. Because a string type data cannot be multiplied with another string type data.

CodePudding user response:

'str' is short for'string', the python data type that holds text. You could try this:

result = text1   " "   text2

Here's the python documentation on strings: https://docs.python.org/3/tutorial/introduction.html#strings

CodePudding user response:

Multiplication can't be take place between two strings, We can only add them .

  • Related