Re: Python programming problem

  • From: Daniel Dalton <d.dalton@xxxxxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Mon, 19 May 2008 19:52:50 +1000 (EST)


Had a quick look: check your if, you use == for assignment statements. (I think.)
(That would return true or false)
(Actually True or False, notice the capital.)
Try using =, but I don't totally understand your program after a quick look so can't be sure.
Also instead of saying
myvar = myvar + yourvar
I think
you could use += as follows:
myvar +=yourvar

HTH.

Cheers,



On Sun, 18 May 2008, Gilbert Neiva wrote:

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


--
Daniel Dalton

http://members.iinet.net.au/~ddalton/
<d.dalton@xxxxxxxxxxxx>
__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts: