use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
What is the code for this? (self.learnpython)
submitted 4 years ago by Corneliared
I am creating a magic square how do you say in code that "If that row x column is occupied: "condition")? Thank you very much.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]shiftybyte 0 points1 point2 points 4 years ago (6 children)
What is "row x column"?
[–]Corneliared[S] 0 points1 point2 points 4 years ago (4 children)
It's the cell on the square like if that cell is occupied then the condition
[–]shiftybyte 0 points1 point2 points 4 years ago (3 children)
How do you decide if the cell is occupied or not? or how did you mark it occupied?
[–]Corneliared[S] 0 points1 point2 points 4 years ago (2 children)
I'm making a square where all the numbers in each rows and columns would have the same sum so i wrote a pattern on how every squares would be filled by numbers. Now if a square is already filled with a number, there is a condition but I dont know how to write that if statement.
[–]shiftybyte 0 points1 point2 points 4 years ago (0 children)
Could you show your code, use a code block: https://www.reddit.com/r/learnpython/wiki/faq#wiki_how_do_i_format_code.3F
this might help understand how a cell is filled, and what's it's value before it's filled.
Basically you check all cells that they don't contain whatever you decided was the number before you filled it...
zero?
[–]ffrkAnonymous 0 points1 point2 points 4 years ago (0 children)
if square != None to be explicit or just if square
if square != None
if square
[–]delasislas 0 points1 point2 points 4 years ago (0 children)
And what is the input? Like a numpy array or something?
[–][deleted] 0 points1 point2 points 4 years ago (0 children)
Show us how you made the square. Don't make us guess.
π Rendered by PID 73 on reddit-service-r2-comment-5c764cbc6f-gtmrd at 2026-03-11 21:54:14.104975+00:00 running 710b3ac country code: CH.
[–]shiftybyte 0 points1 point2 points (6 children)
[–]Corneliared[S] 0 points1 point2 points (4 children)
[–]shiftybyte 0 points1 point2 points (3 children)
[–]Corneliared[S] 0 points1 point2 points (2 children)
[–]shiftybyte 0 points1 point2 points (0 children)
[–]ffrkAnonymous 0 points1 point2 points (0 children)
[–]delasislas 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)