[Tutor] Trouble Removing Whitespace

Jason Durnen jasondurnen at gmail.com
Sun Nov 6 22:25:25 EST 2016


Hello,
I am totally new to programming but thought I would give it a shot. I
recently purchased the Python Crash Course book and have run in to a
problem in the second chapter. The section that talks about removing
whitespace in code to be more precise.

This is the code that I type in, but the result will not trim the extra
space. The first group is how it is shown in the book, but when it prints,
the  '  is not included anywhere.

favorite_language = 'python '
print (favorite_language)
favorite_language = favorite_language.rstrip()
print(favorite_language)

In this section, I added double quotations around the single quotation and
the word python, however I can't get it to remove the whitespace when it
print the word. Is there something that I'm missing?

favorite_language = "'Python '"
print(favorite_language)
favorite_language = favorite_language.rstrip()
print(favorite_language)

The following is the output I get from the two examples I have above:
python
python
'Python '
'Python '
Press any key to continue . . .

Any help you could give me would be greatly appreciated!
Thanks for your time.

Jason Durnen
jasondurnen at gmail.com


More information about the Tutor mailing list