def findSpaces(text): """prints out the locations of the spaces in text""" foundSpace = False for pos in range(len(s)): if s[pos]==" ": print "There's a space in position " + str(pos) + "." foundSpace = True if not foundSpace: print "There are no spaces in this string." return s = raw_input("Enter a string: ") findSpaces(s)