Python #4: How to Implement A Counter

#Programmer: Akinwale Owi
#Company: Dagba Computers
#Program: Purpose: Basic Counter

#Beginning of Program

#Counter variable
counter = 0

#loopBreak is the variable I will be saving responses in
loopBreak = input('Press q to end iteration, or any other letter to keep it going:')

#Beginning of loop
if(loopBreak == 'q'):
    print('Wow you pressed q first')

#If the user did not enter a q
    while(loopBreak != 'q'):
        loopBreak = input('Please enter another letter to tally or press q to quit:')

        #1 Being added to the counter
        counter += 1

    #When the user enters q
        print('You pressed a number of than q,',counter, ' times')

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s