-2
這是假設創建一個函數,該函數可以返回重複n次的字符串,並由用戶需要的字符串delim分隔。我錯過了什麼?如何編程函數返回重複n次的字符串,用字符串delim分隔
def repeat(string, n, delim) :
return (string + delim) * (n - 1)
def main() :
string = input("Enter a string: ")
n = int(input("Enter the number of times repeat: "))
delim = input("Enter the delim: ")
main()