Updating a variable problem.

Souvik Dutta souvik.viksou at gmail.com
Tue Aug 4 04:49:52 EDT 2020


Probably because the MSN variable in the second function is not global.

On Tue, Aug 4, 2020, 2:08 PM Steve <Gronicus at sga.ninja> wrote:

> Why should line 6 fail until line 7 is commented out?
> Python complains that MSN is "referenced before assignment".
>
> def ReadTheEQfile():
>   global MSN
>   MSN = ("1 Monitor") #This line works every time.
>
> def EditTheEQlist():
>   print("MSN2 = " + MSN) # Works if the next line is commented out.
>   MSN = ("3 Monitor")
>
> # Main()
> ReadTheEQfile()
> print("MSN1 = " + MSN) # This line works every time
> EditTheEQlist()
>
>
>
> =====================================
> Footnote:
> Genie: You have three wishes.
> Me: I wish I had more wishes.
> Genie: You cannot wish for more wishes.
> Me: I wish I could.
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>


More information about the Python-list mailing list