Python .strip method not working -


i have function begins this:

def solve_eq(string1):     string1.strip(' ')     return string1 

i'm inputting string '1 + 2 * 3 ** 4' return statement not stripping spaces @ , can't figure out why. i've tried .replace() no luck.

strip not remove whitespace everywhere, @ beginning , end. try this:

def solve_eq(string1):     return string1.replace(' ','') 

using strip() in case redundant (obviously, commentators!).

p.s. bonus helpful snippet before take break (thanks op!):

import re a_string = re.sub(' +', ' ', a_string).strip() 

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -