def mostly_spaces(s): """ Is the string mostly spaces? """ numspaces = 0 for i in range(len(s)): if s[i]==" ": numspaces = numspaces + 1 return numspaces*2 > len(s) s = raw_input("Enter a string: ") if mostly_spaces(s): print "The string you entered is more than half spaces." else: print "The string you entered is not more than half spaces."