I want to create a list which will list coordinates on a 50 by 50 grid. I have been able to set the x-value from 0 to 49, while maintaining the y-value as 0. When I try to reset the x-value back to 0, and increment the y-value by 1- my code does not work. Could you help?

(x,y)=(0,0)
lst = []

answer = True
for x in range (50):
    lst=lst+[(x,y)]
    if (x>=49): 
        (x,y)=(0,y+1)
        answer = True
print lst
list1 = []

for y in range(50):
    for x in range(50):
        list1.append((x, y))

print list1

Cheers and Happy coding

Could someone help me? I don't understand why python won't return the list.

from conwayLibrary import *
setupGame()
displayBoard()

lst = []

for y in range(50):
    for x in range(50):
        lst.append((x, y))

        return lst

You have not called any function, therefore you can not return.

Thread closed as there is double here

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.