I m very new to Python and am trying to teach myself a few things using various online resources. In the WIkipedia article on algorithms, there is a sample BASIC program; I ve decided to try and write the same program using Python, but I am running into problems with the syntax of my if/else statements. I m pretty sure it s a basic formatting problem, but I don t have enough experience with coding to understand what I m doing wrong. The following chunk of code:
# Euclid s algorithm for greatest common divisor print "Euclid s algorithm for greatest common divisor" print "Type two integers greater than 0" (" ") ("a") # Gather input from user in the form of a string. (" ") a = raw_input("Integer 1? ") (" ") b = raw_input("Integer 2? ") (" ") # Calculate equalities. if b = 0: print a elif a > b: a = a - b print a b = b - a if b = 0: print a
returns the error:
File "euclid.py", line 35 if b = 0: ^ SyntaxError: invalid syntax
I realize the module as a whole is incomplete, but I would like to try to figure out what I m doing wrong in this part before I move on to the next part.