How to perform two functions in a single for loop in python
<p>I wanna split a sentence and also replace quotes from it. I did:</p>

<pre><code>sentences = read_data.split('\n')

sentences_no_quotes = [sentence.replace('"', '') for sentence in sentences]

splited_sentences = [sentence.split(',') for sentence in sentences_no_quotes]
</code></pre>

<p>How can I do it in a single line? any suggestions! Thanks for the help</p>

<p>Just do it, it's straightforward.</p>

<pre><code>splited_sentences = [sentence.split(',') for sentence in
                     [sentence.replace('"', '') for sentence in
                      read_data.split('\n')]]
</code></pre>

<p>Probably you'd better use generators instead of lists but that's beyond your question.</p>

python python-3.x