Home > Software design >  How can i check in first List index 1 is greater than second list index 0, and first List index 2 is
How can i check in first List index 1 is greater than second list index 0, and first List index 2 is

Time:12-08

I have Three lists -

High:  [18365.5, 18979.25, 19297.4, 19874.8, 20288.0, 20504.65, 20398.2]
Low:  [17855.5, 18265.0, 18822.55, 18742.15, 19492.55, 20055.55, 20131.25]
Close:  [18317.05, 18969.95, 18857.6, 19804.0, 20260.15, 20285.0, 20215.7]

And I want to check

if Close [index1] > Low [index0]
   print("XYZ")
elif Close[index1] < High[index0]
   print("XYZ")

and as do the same for the rest of the indexes in close.

if Close [index2] > Low [index1]
   print("XYZ")
elif Close[index2] < High[index1]
   print("XYZ")

Please Help me to solve this problem. I don't understand how can I do this.

CodePudding user response:

Solution as asked by you.

Correct Solution would be checking same index for all list, considering its Stock Market.

high = [18365.5, 18979.25, 19297.4, 19874.8, 20288.0, 20504.65, 20398.2]
low =  [17855.5, 18265.0, 18822.55, 18742.15, 19492.55, 20055.55, 20131.25]
close =  [18317.05, 18969.95, 18857.6, 19804.0, 20260.15, 20285.0, 20215.7]


for i in range(len(high)-1):
    if (close[i 1] > low[i]) and (close[i 1] < high[i]):
        print("Valid Indices")
    else:
        print("Invalid: Correct Sequence: Low < Close < High")

Suggestion: Low =< Close =< High

  • Related