Anonymous asked in Computers & InternetProgramming & Design · 1 month ago

Why does .rstrip() work for list comprehensions but not for for loops?

I know it's a string method, but what's the difference? 


Why would I have to show code for this question??? Like what?

Update 2:

When did I say "I WISH" it to? I'm asking about the how the language works. 

Update 3:

All of that TV has melted your brain.

Update 4:

I was not talking to husoski Brilliant_movies, the commenter I was replying to was removed because he broke Yahoo's rules and was being a douche.

2 Answers

  • 1 month ago
    Favorite Answer

    So far, the correct answer seems to be, "Who *said* that .rstrip() doesn't work with for loops?"

    For example:

        for c in 'abc \n'.rstrip():


    So, you seem to be doing something else that doesn't work; and then blaming that on .rstrip().  *That's* why you need to show someone who feels helpful might show you what your misconception is.

  • 1 month ago

    You wrote: Why does .rstrip() work for list comprehensions but not for for loops?" Well, it does work for for loops, as @Husoski has kindly showed you, giving an example to back it up. I think he deserves more respect for sharing his wisdom here, for free.

Still have questions? Get your answers by asking now.