+ 1
What is happening?
Can you explain me what is happening in this codes?
4 Answers
+ 5
1. Sololearn playground
2. "\" is used to escape character sequences. "\\" should escape the "\". As neither "\s" nor "\spec" is an escape sequence in Python, "\" can safely be interpreted as "\" which may be why the interpreter accepts it without error.
3. text_pro=text does not copy the list. "text_pro" is only a reference to the same list that is stored in "text", hence you are appending to the same list tha tyou are iterating.
+ 2
This reading will help you understand better the third problem.
https://inventwithpython.com/beyond/chapter8.html#calibre_link-172
In short, it is bad to modify an iterable while you are looping at it.
0
Here my code update đż. Upvote âš
https://sololearn.com/compiler-playground/cPn2D3N214G0/?ref=app