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
else:
    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
    else:
        print('You pressed a number of than q,',counter, ' times')

Leave a comment