[Solved] I am writing a program that generates a list of integer coordinates for all points in the first quadrant from (1, 1) to (5, 5) [closed]


In the first line you have written first_quadrant as 1 which is an integer. In the second line you are trying to use a for loop over an integer. This is not allowed and therefore the error.

You could do it in many other ways. I am writing two such possible solutions.

Solution 1

first_quadrant = 1
last_quadrant = 5
coordinates = []
for x in range(first_quadrant,last_quadrant +1, 1):
    for y in range(first_quadrant,last_quadrant +1, 1):
        coordinates.append([x,y])
print(coordinates)

Solution 2

coordinates = [[x,y)] for x in range(1, 5+1,1) for y in range(1, 5+1, 1)]
print(coordinates)

solved I am writing a program that generates a list of integer coordinates for all points in the first quadrant from (1, 1) to (5, 5) [closed]