You have this within the loop, when it only needs to execute once ...
pyg = 'ay'
The simplest way to process the user's input might be to do it as @stetim94 has suggested above.
If you opt for a list comprehension instead, you can also simply the code quite a bit. You would need to get rid of the
for loop, since it would become unnecessary, and revise this comprehension, which cannot work ...
[ i.replace(i, i + first + pyg) for i in sentence if first = i and i = i[1:len(i)]]
if, in the above, where only conditions should go, you used the
= operator instead of
== . If those were actually intended as assignments, you could refactor them into an expression to replace the named variables that you have in the
for loop, and then place that expression in the list comprehension prior to the
Whichever direction you choose to take, please post your revised code if you have any questions, or if you just want to show us the finished product.