clean Write a function clean that when is given a string and returns the string with the leading and trailing space characters removed. Details: you must use while loop(s) you must not use the strip method • the space characters are the space , newline '\n', and tab '\t' >>> clean (" 'hello' hello ") >>> clean ("hello, how are you? ") 'hello, how are you?' >>> clean ("\n\n\t what's up, \n\n doc? \n \t") "what's up, \n\n doc?" >>> clean ("\n\n\t\ what's up, \n\n doc? \n \t")=="what's up, \n\n doc?" True

icon
Related questions
Question
clean
Write a function clean that when is given a string and returns the string with the leading and
trailing space characters removed. Details:
you must use while loop(s)
you must not use the strip method
• the space characters are the space
, newline '\n', and tab '\t'
>>> clean ("
'hello'
hello
")
>>> clean ("hello, how are you? ")
'hello, how are you?'
>>> clean ("\n\n\t what's up, \n\n doc? \n \t")
"what's up, \n\n doc?"
>>> clean ("\n\n\t\ what's up, \n\n doc? \n \t")=="what's up, \n\n doc?"
True
Transcribed Image Text:clean Write a function clean that when is given a string and returns the string with the leading and trailing space characters removed. Details: you must use while loop(s) you must not use the strip method • the space characters are the space , newline '\n', and tab '\t' >>> clean (" 'hello' hello ") >>> clean ("hello, how are you? ") 'hello, how are you?' >>> clean ("\n\n\t what's up, \n\n doc? \n \t") "what's up, \n\n doc?" >>> clean ("\n\n\t\ what's up, \n\n doc? \n \t")=="what's up, \n\n doc?" True
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer