samedi 4 avril 2015

Why does this if statement give an error, and what can i do to fix it?

this code should return the squares of the numbers up to the specified number, it also has to give an error message if the user enters 0.



def print_sqrs_1_to_number(number):
"""prints the squares of 1 to defined number"""
if number = 0:
print("ERROR: number must be at least 1.")

else:
for i in range(1, number + 1):
numbers = i * i
print(i,"*", i, "=", numbers)


`


Aucun commentaire:

Enregistrer un commentaire