Nov-04-2018, 01:22 PM
(This post was last modified: Nov-04-2018, 01:22 PM by gontajones.)
You have to return the new (modified) string.
def checker(string): for i in range (len(string)): if " " in string: string = string.replace(' ','') elif "-" in string: string = string.replace('-','') return stringA better way to write this function:
def checker(s): return s.replace(' ','').replace('-','')The
replace()
already search in every char of the string.