Removing all space in Python

Source code :

sentence = ' hello  apple  '
sentence=sentence.replace(" ","")
print(sentence)

Output :

helloapple

Algorithm :

  1. Declare a variable with values
  2. Declare a replace function to remove the spaces using the syntax .replace(" ","")
  3. Finally print the result

Output :


                

Comments :