Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

The first coordinates never work, but the following work

This is not full code, but the question is in coordinates. The first time you type coords, code just ignore them, but if you type the same coords second time, code will work properly. Help please

b = input()
coords = b.split()
coordinates_x = int(coords[0])
coordinates_y = int(coords[1])

new_list = [x for x in a]
for i in range(3):
    line_1.append(new_list[i])
    line_2.append(new_list[i + 3])
    line_3.append(new_list[i + 6])

# залупа ебаная
while True:
    b = input()
    coords = b.split()
    coordinates_x = int(coords[0])
    coordinates_y = int(coords[1])
    if (3 >= coordinates_y >= 1) and (3 >= coordinates_x >= 1):
        if coordinates_x == 1:
            if new_list[coordinates_y - 1] == "_":
                new_list[coordinates_y - 1] = "X"
                pechat(new_list)
                break
            elif new_list[coordinates_y - 1] == "X" or new_list[coordinates_y - 1] == "0":
                print("This cell is occupied! Choose another one!")
                continue
        elif coordinates_x == 2:
            if new_list[coordinates_y + 2] == "_":
                new_list[coordinates_y + 2] = "X"
                pechat(new_list)
                break
            elif new_list[coordinates_y + 2] == "X" or new_list[coordinates_y + 2] == "O":
                print("This cell is occupied! Choose another one!")
                continue
        elif coordinates_x == 3:
            if new_list[coordinates_y + 5] == "_":
                new_list[coordinates_y + 5] = "X"
                pechat(new_list)
                break
            elif new_list[coordinates_y + 5] == "X" or new_list[coordinates_y + 5] == "O":
                print("This cell is occupied! Choose another one!")
                continue
    elif (3 < coordinates_y or coordinates_y < 1) or (3 < coordinates_x or coordinates_x < 1):
        print("Coordinates should be from 1 to 3!")
    

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Those first four lines:

b = input()
coords = b.split()
coordinates_x = int(coords[0])
coordinates_y = int(coords[1])

just take input and do nothing with it. That’s why the first coords you enter don’t do anything. Just remove those lines and it should work.

The code inside the while loop takes the input and actually runs the calculations on it, so you must leave it in place. The 4 at the top look like leftovers from an earlier version of the program before the while loop.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading