My homework question is this:
Python allows you to repeat a string by multiplying it by an integer, e.g. 'Hi' * 3 will give 'HiHiHi'. Pretend that this feature does not exist, and instead write a function named repeat that accepts a string and an integer as arguments. The function should return a string of the original string repeated the specified number of times, e.g. repeat('Hi', 3) should return 'HiHiHi'.
And I answered it as following:
def repeat(string,number):
fstring = ""
for var in range(1,number+1):
fstring+=fstring+string
print(fstring)
repeat("Hi",3)
But the result is not what I had expected:
HiHiHiHiHiHiHi
. I am not able to see the mistake, help me!