Count how many times a variable is called
<p>I want to add something that will count how many times a variable is used (like variable <code>c</code>) and output in number of times variable <code>c</code> was used. What functions can I use? Here's the code:</p>

<pre><code>#! /usr/bin/python

question = raw_input
y = "Blah"
c = "Blahblahb"


print "Is bacon awesome"
if question() = "Yes":
    print y
else:
    print c

print "Blah"
if question() = "Yes":
    print y
else:
    print c
</code></pre>

<p>You could have a counter variable. Lets call it 'count'. Every time you print c, you increment count by 1. I've pasted the code below. You can print the count variable in the end</p>

<pre><code>question = raw_input
y = "Blah"
c = "Blahblahb"

count=0

print "Is bacon awesome"
if question() == "Yes":
    print y
else:
    count+=1
    print c

print "Blah"
if question() == "Yes":
    print y
else:
    count+=1
    print c

print c
</code></pre>

python variables counting