Remove White spaces in Python using Strip() function

  • Python String is immutable, which means we can’t change its value. Any function that manipulates string value returns a new string and we have to explicitly assign it to the string. Otherwise, the string value cannot change.
  • Python String strip() function will remove leading and trailing whitespaces.
        Ex: string1 = " Hello World.  Good Morning "
    
        >> string1.strip()
        
        "Hello World.  Good Morning"


Comments

Popular posts from this blog

Internationalization (Language Setting) in Django

reverse_lazy() Method in Django

CharFilter in Django