masukkan karakter ke dalam string pada posisi x python
def ins(a,b,c):
return a[:c]+b+a[c:]
a is original string
b is inserted character
c is position
#with error handling
def ins(a,b,c):
if type(a)!=str:
raise("TypeError: Ins takes first arg as a string.")
elif type(b)!=str:
raise("TypeError: Ins takes second arg as a string.")
elif type(c)!=int:
raise("Type error: Ins takes an int for position")
return a[:c]+b+a[c:]
Thankful Toucan