I’m a bit new to python and can’t figure out why this is not working.
I have a variable that is something like this:
[u'\n Data I want ']
but I also have variables that are simply:
[u' more Data I want ']
I am running the variables through a loop but I need to strip all the extra stuff around the data. I created a function to deal with this but I’m not sure why its not working(I’m not sure but I suspect \n is a special character)
def stripName(name):
name = str(name)
if name.startswith( "\n" ):
print "starts with new line"
name = name[5:-2]
else:
print "does not start with new line"
name = name[3:-2]
return name
The problem is the “if name.startswith( “\n” )” never matches..I’ve looked at other examples and I think I’m doing it as they are. I even triedif name.startswith( "\n" ) == 'True': but that didn’t work either.
Thanks in advance for any insight you guys can give.
How about:
?