Python Forum
Cant access variable from anywhere
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cant access variable from anywhere
#17
Works fine for me.
cma = 0
max_close = 10000
for index in range(10):
    fibo = (max_close - (3853.5)) / (max_close - cma)  # Will use current cma value, not always zero
    print(fibo, cma)
    cma = cma + 100
0.61465 0
0.6208585858585859 100
0.6271938775510204 200
0.6336597938144329 300
0.6402604166666667 400
0.647 500
0.6538829787234043 600
0.6609139784946236 700
0.6680978260869566 800
0.6754395604395604 900
Of cource cma may not change based on the equations used to calculate cma.
cma = 0  # <- Assigned outside any loop
max_close = 10000
for index in range(10):
    fibo = (max_close - (3853.5)) / (max_close - cma)  # Will use current cma value, not always zero
    print(fibo, cma)
    cma = cma **2
Output:
0.61465 0 0.61465 0 0.61465 0 0.61465 0 0.61465 0 0.61465 0 0.61465 0 0.61465 0 0.61465 0 0.61465 0
If you initialize cma = 0 outside of any loop and assign a different value to cma inside the loop, fibo will change value.
Reply


Messages In This Thread
Cant access variable from anywhere - by Frankduc - Nov-01-2022, 12:51 PM
RE: Cant access variable from anywhere - by rob101 - Nov-01-2022, 01:04 PM
RE: Cant access variable from anywhere - by rob101 - Nov-01-2022, 01:29 PM
RE: Cant access variable from anywhere - by deanhystad - Nov-02-2022, 03:22 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  sharepoint: Access has been blocked by Conditional Access policies CAD79 0 2,246 Jul-12-2024, 09:36 AM
Last Post: CAD79
  Can we access instance variable of parent class in child class using inheritance akdube 3 15,805 Nov-13-2020, 03:43 AM
Last Post: SalsaBeanDip
  Access a variable of a daemon peek_no_boo 8 4,899 Apr-03-2020, 07:29 PM
Last Post: BrendanD
  How to access class variable? instances vs class drSlump 5 4,414 Dec-11-2019, 06:26 PM
Last Post: Gribouillis
  How can I access this variable from a def? student3m 1 3,503 Sep-23-2017, 02:06 PM
Last Post: ichabod801
  Can access class private variable? Michael 2 8,214 Aug-11-2017, 01:59 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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