#A random string with lot of spaces at before in middle and after.
string = " I love cheese and grapes "
#remove the extra spaces at the begining and the end of the string
while string == " ":
string = string[1:]
while string[-1] == " ":
string = string[:-1]
#use a list to store the characters you want to keep from the original string
new_string = 
for i in range(len(string)):
if string[i] == " " and string[i+1] ==" ":
#Use .join to concatenate the list data back to a string.
new_string = "".join(new_string)
Still unsure to how much extend about the “no built-in functions”. like append(), join() or even replace()
while " " in string:
string = string.replace(" ", " ")