ckloi / Scripting-Languages

0 stars 1 forks source link

strip() and replace() #27

Closed Ajfaust closed 7 years ago

Ajfaust commented 7 years ago
#remove the whitespace characters
            i.strip()
            #remove the empty spcace
            nkeys = i.replace(' ', ',')

I'm having a bit of trouble trying to understand what's going on here. From what I understand, strip() should remove all whitespace from the string, but then you try to replace all spaces with ','s. If you just removed all the whitespace, shouldn't there be no spaces?

tihju commented 7 years ago

it should just remove the '\n', screen shot 2017-02-09 at 6 39 26 pm

tihju commented 7 years ago

here is the link: http://www.pitt.edu/~naraehan/python2/string_methods1.html

Ajfaust commented 7 years ago

Ah ok thanks for clearing that up

Edit: readlines returns a list of strings without '\n' though