+ 1

What is happening?

Can you explain me what is happening in this codes?

28th Dec 2024, 10:52 AM
MaziarDX
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.
28th Dec 2024, 12:43 PM
Lisa
Lisa - avatar
+ 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.
28th Dec 2024, 2:20 PM
Wong Hei Ming
Wong Hei Ming - avatar
0
Here my code update 🗿. Upvote ✹ https://sololearn.com/compiler-playground/cPn2D3N214G0/?ref=app
29th Dec 2024, 7:21 AM
ᑎOᑌᗰᗩᑎ ᑕOá—ȘIᑎG 🇾🇬
ᑎOᑌᗰᗩᑎ ᑕOá—ȘIᑎG   🇾🇬 - avatar