Python Forum
Global Variable Not Updating
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Global Variable Not Updating
#2
In main lines 28-29 you call take_option_loss and pass it option_ceiling.
In the take_option_loss function you receive option_ceiling but then declare a global option_ceiling, and you return option_ceiling. Which option_ceiling, from which namespace? I'm confused and the interpreter will be too.

If you comment out the global statement (line 4) and then make sure your return statement variable order is the same as in the calling statement (line 27 in main vs line 13 in the function) it should work. I expect that scrambling the order of the variables in the return statement ended up assigning option_ceiling the intended value for option_floor...
Reply


Messages In This Thread
Global Variable Not Updating - by joew - Jan-26-2020, 01:05 PM
RE: Global Variable Not Updating - by jefsummers - Jan-26-2020, 02:01 PM
RE: Global Variable Not Updating - by joew - Jan-26-2020, 04:15 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  It's saying my global variable is a local variable Radical 5 1,243 Oct-02-2023, 12:57 AM
Last Post: deanhystad
  Variable scope - "global x" didn't work... ptrivino 5 3,113 Dec-28-2020, 04:52 PM
Last Post: ptrivino
  Spyder Quirk? global variable does not increment when function called in console rrace001 1 2,268 Sep-18-2020, 02:50 PM
Last Post: deanhystad
  NameError for global variable leviporton 3 2,595 Jul-10-2020, 06:51 PM
Last Post: bowlofred
  Variable Not Updating NectDz 1 2,854 Jun-07-2020, 11:21 PM
Last Post: bowlofred
  Function Recognises Variable Without Arguments Or Global Variable Calling. OJGeorge4 1 2,295 Apr-06-2020, 09:14 AM
Last Post: bowlofred
  Variable not updating Rayaan 3 6,099 Mar-29-2020, 04:42 PM
Last Post: SheeppOSU
  Help with Global/Coerced Variable (Understanding Scope) Rev2k 6 3,590 Jan-09-2020, 03:43 AM
Last Post: Rev2k
  Declaring a Global Variable in a Function Bob1948 4 3,108 Sep-14-2019, 11:16 PM
Last Post: ichabod801
  Global variable does not seem to be global. Columbo 6 3,769 Jul-15-2019, 11:00 PM
Last Post: Columbo

Forum Jump:

User Panel Messages

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