Mohammad Anbar
Mohammad Anbar

Reputation: 25

adding two while loops inside a function

below is a summary of the current code, I'm trying to test all values of weight1 & weight2 as a loop to be used inside a function, but the results I'm getting is not correct, would guys please advise, thx

weight1 = 0.95
weight2 = 0.05
while weight1 >= 0.05:
    weight1 -= 0.05
while weight2 <= 0.95:
    weight2 += 0.05


def mod(dates):
    df1['score'] = ((df1['EY_rank'] * weight1) + (df1['ROIC_rank'] * weight2)) / 2
    print(result)
    for i in dates:
        mod(i)

Upvotes: 0

Views: 78

Answers (1)

G. C.
G. C.

Reputation: 427

Intendation is very important in Python, since it is the way to define statements blocks.

The first while-loop executed is

while weight1 >=0.05:
    weight1-=0.05

at the end you use weight1=0.05 in the next while loop

Upvotes: 1

Related Questions