# Re: Python programming problem

• From: Gilbert Neiva <gneiva@xxxxxxx>
• To: programmingblind@xxxxxxxxxxxxx
• Date: Sun, 18 May 2008 19:30:16 -0600

```Thanks. It worked. I always thought that in an if statement, you always need
two equal signs if something equaled something else. But I got rid of the extra
equal signs and the program works the way I want it to now. It produces the
right sequence of numbers.

Gilbert Neiva

----- Original Message -----
From: rrdinger
To: programmingblind@xxxxxxxxxxxxx
Sent: Sunday, May 18, 2008 5:52 PM
Subject: Re: Python programming problem

Hi Gilbert,

I'm not certain exactly what sequence you are trying to produce, but I think
the statements you have in your if block are probably wrong.

You have:
if count == new_count:
new_count == new_count+2
c == c+1

Those two statements are comparisons and result in either True or False, you
probably want:

if count == new_count:
new_count = new_count+2
c = c+1

A handy short hand for such statements is:
if count == new_count:
new_count += 2
c += 1

HTH

Richard
----- Original Message -----
From: Gilbert Neiva
To: programmingblind@xxxxxxxxxxxxx
Sent: Sunday, May 18, 2008 10:38 AM
Subject: Python programming problem

I am trying to make a program that makes the math sequence 2, 4, 7, 10, 14,
18, 23, 28 and so on. But when I run the program it does the math sequence 2,
4, 6, 8, 10 and so on. Here is the program code below.

#The following program will calculate the following math sequence
#2 4 7 10 14 18 23 28 and so on.

#The following lines will create three variables a, b, and c with
#values of 2, 0, and 0
a = 2
b = 0
c = 0
#The following line will create a variable count
#with  a value of 0
count = 0
#The following line will create a variable new_count
#with a value of 2
new_count = 2
#The following line will create a variable max_count
#with a value of 30
max_count = 30
while count < max_count:
#The above line while count < max_count:
#tells the program to loop until the variable
#count reaches 30
#The following line will create a variable d
#witch will equal the formula a+b+c
d = a+b+c
#The following line will make b equal to d
#as the program runs, the values within these two variables will change
b = d
#The following line will increase the variable count by 1
#each time the program loops
count = count+1
#The following if statement will tell the program to increase
#the new_count variable by 2 and the c variable by 1
#if the count variable is equivalent to the new_count variable
if count == new_count:
new_count == new_count+2
c == c+1
#The following line will display the value of d
#As the program loops, the output will not go line by line
print d,

What am I doing wrong?

Gilbert Neiva
```