>>>”
>>>”
The general format is: string * n Where n is a number of type int. Using the * operator repeats the string n number of times. For example: >>> >>> s = "www " * 5 # repeat "www " 5 times >>> s 'www www www www www ' >>> >>> >>> >>> print("We have got some", "spam" * 5) We have got some spamspamspamspamspam >>> Note that 5 * "www " and "www " * 5 yields the same result. Python can’t multiply strings by non-int data types and will show an error if you use a different data type for n. For example: Traceback (most recent call last): File "", line 1, in TypeError: can't multiply sequence by non-int of type 'str' >>> >>> >>> "www" * 1.5 # n is a float Traceback (most recent call last): File "", line 1, in TypeError: can't multiply sequence by non-int of type 'float' >>>
9. Use slicing operators [start_index:end_index] to get a slice of a string.