print("*" * 10) this line in python print * 10 times.
However the when trying to print("*" + 10) there is a type error.
Why is there a difference in operator behaviour with str and int
>Solution :
That’s because + is a concatenator in Python, and you can concatenate two strings but not a string and an int. You can, of course, cast the int into a string and concatenate that with another string if that’s what you want to do: print("*" + (str(10)))
The thing works with * because that operator will simply concatenate the string with itself as many times as indicated by the integer number, as you’ve observed.