Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Global vs. Local Variables
#1
I know I will probably be flamed for this question, but after 12 hours of researching and trying, this is my last resort. I know it is probably something simple I am overlooking, but now I have tunnel vision cant see it.

Question: How do I update an empty list at the global level, by passing a parameter to a function?

Example:

    >>> A = [] 
    >>> def Update(A = []):
            print("A =", A)
    >>> Update(44)
    A = 44
    >>> A
    []
buran write Jan-06-2021, 09:46 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Reply


Messages In This Thread
Global vs. Local Variables - by Davy_Jones_XIV - Jan-06-2021, 09:18 PM
RE: Global vs. Local Variables - by Larz60+ - Jan-06-2021, 09:54 PM
RE: Global vs. Local Variables - by buran - Jan-06-2021, 09:54 PM
RE: Global vs. Local Variables - by deanhystad - Jan-06-2021, 10:06 PM
RE: Global vs. Local Variables - by Davy_Jones_XIV - Jan-06-2021, 10:22 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  It's saying my global variable is a local variable Radical 5 1,098 Oct-02-2023, 12:57 AM
Last Post: deanhystad
  Trying to understand global variables 357mag 5 1,065 May-12-2023, 04:16 PM
Last Post: deanhystad
  Delete all Excel named ranges (local and global scope) pfdjhfuys 2 1,690 Mar-24-2023, 01:32 PM
Last Post: pfdjhfuys
  Global variables or local accessible caslor 4 985 Jan-27-2023, 05:32 PM
Last Post: caslor
  global variables HeinKurz 3 1,102 Jan-17-2023, 06:58 PM
Last Post: HeinKurz
  How to use global value or local value sabuzaki 4 1,106 Jan-11-2023, 11:59 AM
Last Post: Gribouillis
  Clarity on global variables JonWayn 2 905 Nov-26-2022, 12:10 PM
Last Post: JonWayn
  Global variables not working hobbyist 9 4,618 Jan-16-2021, 03:17 PM
Last Post: jefsummers
  Global - local variables Motorhomer14 11 4,128 Dec-17-2020, 06:40 PM
Last Post: Motorhomer14
  from global space to local space Skaperen 4 2,269 Sep-08-2020, 04:59 PM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020