r/pythonhelp • • Jun 08 '21

Can anybody help me with this script? In the output panel, it is supposed to send the coordinates of the 'k,' but it instead sends random numbers (Wherever I put the 'k'). However, for example, it is at (3, 3), but (0, 2) shows up in the output regardless of how many times I run it.

Post image
2 Upvotes

6 comments sorted by

3

u/Akshaykadav Jun 09 '21

The output that you get is correct indexing starts at 0 in almost all programming launguages. To get a user friendly location you can just add +1 to i and j and the output should now be (1,3) so the 1st row and the third column.

1

u/[deleted] Jun 11 '21 edited Jun 11 '21

Thank you!

1

u/[deleted] Jun 11 '21

Wait, how would I add that +1 value to them? Sorry, I'm kinda new to Python (And programming in general).

1

u/Akshaykadav Jun 12 '21

When you return add 1 to it. return (i+1 , j+1)

1

u/[deleted] Jun 12 '21

Alright, thank you!!

1

u/MrPhungx Jun 08 '21

In arrays and lists you start counting the index at 0. Therefore a row or column has the Indizes 0, 1, 2. So the position of k in your screenshot is the row 0 and the column 2 which results in (0,2).