Computer Science

How does '*' operator behave on strings?

Python String Manipulation

3 Likes

Answer

The * operator creates a new string by repeating multiple copies of the same string.

For example,

string = "abc"
repeated_string = string * 3
print(repeated_string)
Output
abcabcabc

In the above example, the string "abc" is repeated 3 times to produce "abcabcabc".

Answered By

1 Like


Related Questions