0

Ok so I'm creating a loop:

def equ(par1,par2):
    con1=4/par1

    ready=False
    add=False

    if ready==True:
        if add==True:
            par2+=con1
            add=False
            print("true")
        elif add==False:
            par2-=con1
            add=True
            print("False")
    elif ready==False:
        par2=con1
    ready=True
    input()
    return par2

Every time I run the program it doesn't do what it's supposed to. I notice that it will NOT change ready to true. Could any one give me some help? THANKS! :)

4
  • 2
    You do not have a loop here. You are just giving an if conditional. what are you trying to do ? Commented Apr 14, 2013 at 21:04
  • Urgh. ready = True??? Commented Apr 14, 2013 at 21:12
  • 1
    You should consider using if ready: instead of if ready==True: and if not ready: instead of if ready==False: Commented Apr 14, 2013 at 21:13
  • Never mind guys I figured it out! :) Commented Apr 14, 2013 at 21:45

1 Answer 1

1

First, you have no looping construct. You only have a linear flow of logic.

Second, ready==True will never be true, since it is explicitly set to False before that code block is ever hit.

If you're intending to reuse the boolean value ready, then you'd either want to preserve its state somewhere outside of the scope of the method - once you leave the method, it goes right back through and sets it to False again.

Sign up to request clarification or add additional context in comments.

3 Comments

I have a loop outside it! :/ But thank you. You DID help me. I'm just going to change it up a little then check. Once I'm done with that could you help me out with the second error? I'll tell you in a minute.
That may take it outside of the scope of the question, and I've got a few things to do...I don't mind helping, but you may be better off creating a new question to solve your other problems.
Well it has to do with the same thing...But OK! I'll make a new question! Thanks for the help! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.