-1
phrase = "This is amazing"
print("How many characters in the variable phrase " + len(phrase) + "this are the numbers")

It says that can only concatenate str (not "int") to str

Henry Ecker
  • 34,399
  • 18
  • 41
  • 57
  • 1
    try `str(len(phrase))`; a length is often numerical – Ronald Oct 11 '21 at 07:20
  • 1
    Does this answer your question? [How can I concatenate str and int objects?](https://stackoverflow.com/questions/25675943/how-can-i-concatenate-str-and-int-objects) – Henry Ecker Oct 15 '21 at 03:26

1 Answers1

0

The case is that you can't concatenate string with integer, since len(phrase) returns the length from phrase that is why you are getting that error. So you cant convert the integer number to string and then concatenate in this way:

phrase = "This is amazing"
print("How many characters in the variable phrase " + str(len(phrase)) + "this are the numbers").

I suggest to use join function for better result when you concatenate strings

Nederxus
  • 65
  • 1
  • 5