Q:

How do I add a number to another everytime a loop repeats

So at school, our teacher asked us to make a program which needs a password to grant access. I have made this however i would like to improve on it by adding a loop count which increase each time it loops round heres what i have so far for the loop count, however it doesn't work.
import time
b=0
a='apple'

def start():
    print("enter password")
    c=input("->  ")
    if c==a:
        grant()
    else:
        delay()

def grant():
    end

def delay():
    b=b+1
    time.sleep(b)
    start()

start()

A:

Python doesn't recognize b in delay() because it is in global scope.
Try this:
def delay():
    global b
    b=b+1
    time.sleep(b)
    start()

A:

Your problem is inside here:
def delay():
    b=b+1
    time.sleep(b)
    start()

When you do b = b + 1, you're expecting the b variable at the top of the file to increase by 1, right?
You probably haven't learned this yet, but the reason why this doesn't work is because of something called scope.
To fix it, you need to change your delay function to look like this:
def delay():
    global b
    b=b+1
    time.sleep(b)
    start()

From looking at your code, I take it you haven't learned how to use while loops yet? 
Your solution of repeatedly calling start inside of delay is actually pretty clever. However, if we use a while loop, we can rewrite your program so that it's a little cleaner and more obvious as to what you're trying to do:
import time

password = 'apple'

def start():
    counter = 0
    user_guess = ''

    while user_guess != password:
        print("enter password")
        user_guess = input("->  ")
        if user_guess != password:
            counter += + 1          # Same thing as doing `counter = counter + 1`
            time.sleep(counter)

    grant()

def grant():
    print "Access granted!"

start()

