This is a weird behavior.
Try this :
rep_i=0 print \"rep_i is\" , rep_i def test(): global rep_i #without Global this gives error but list , dict ,
You only need to use global if you are assigning to the global name. Without global, an assignment creates a new local.
global
There's nothing special about how global applies to a list—global simply influences scope and name resolution.