Square number sequence in Python
问题 I'm new to python and I am trying to make a code to print all the square numbers until the square of the desired value entered by the user. n = raw_input("Enter number") a = 1 while a < n: a = 1 print(a*a) a += 1 if a > n: break When I run this code it infinitely prints "1" ... I'm guessing that the value of a does not increase by += so it's a=1 forever. How do I fix this? 回答1: There are some problems. First, your input (what raw_input() returns) is a string , so you must convert it to