This is 4th day learning how to code, I'm still a little confused about some of the basics.It has pygame, pygame.text,So essentially my code looks like this.#Mouse click to get mouse Positionif event.type == pygame.MOUSEBUTTONDOWN:if gamestage == 0 and gamestage <= 1:gamestage += 1mx, my =pygame.mouse.get_pos()#Total rectangle dimentions mx>806 and mx<889 and my>890 and my<920#Clickable squares for Shots and Team#Use print function if bug arisesif mx>848 and mx<889 and my>890 and my<920:#numberonscreen_x=859#numberonscreen_y=905n+=1print(n)n=str(n)text_surface, rect = gamefont.render(n,(4, 8, 18))n=int(n)screen.blit(board,(0,0))pygame.display.flip()if mx>806 and mx<848 and my>890 and my<920:print("Pass")if mx>764 and mx<806 and my>890 and my<920:print("Pass")if mx>722 and mx<764 and my>890 and my<920:print("Pass")if mx>680 and mx<722 and my>890 and my<920:print("Pass")if mx>638 and mx<680 and my>890 and my<920:print("Pass")if mx>596 and mx<638 and my>890 and my<920:print("Pass")if mx>554 and mx<596 and my>890 and my<920:print("Pass")if mx>512 and mx<554 and my>890 and my<920:print("Pass")if mx>470 and mx<512 and my>890 and my<920:print("Pass")if mx>428 and mx<470 and my>890 and my<920:print("Pass")if mx>386 and mx<428 and my>890 and my<920:print("Pass")if mx>344 and mx<386 and my>890 and my<920:print("Pass")if mx>302 and mx<344 and my>890 and my<920:print("Pass")if mx>260 and mx<302 and my>890 and my<920:print("Pass")if mx>218 and mx<260 and my>890 and my<920:print("Pass")if mx>176 and mx<218 and my>890 and my<920:print("Pass")if mx>134 and mx<176 and my>890 and my<920:print("Pass")if event.type == pygame.MOUSEBUTTONUP:if gamestage != 0:gamestage = 0#Press 0 set given on screen button to zeroif event.type == pygame.KEYDOWN and event.key == pygame.K_0:mx, my =pygame.mouse.get_pos()if mx>848 and mx<889 and my>905 and my<920:n=0print(n)if mx>806 and mx<848 and my>905 and my<920:print("Pass1")if mx>764 and mx<806 and my>905 and my<920:print("Pass1")if mx>722 and mx<764 and my>905 and my<920:print("Pass1")if mx>680 and mx<722 and my>905 and my<920:print("Pass1")if mx>638 and mx<680 and my>905 and my<920:print("Pass1")if mx>596 and mx<638 and my>905 and my<920:print("Pass1")if mx>554 and mx<596 and my>905 and my<920:print("Pass1")if mx>512 and mx<554 and my>905 and my<920:print("Pass1")if mx>470 and mx<512 and my>905 and my<920:print("Pass1")if mx>428 and mx<470 and my>905 and my<920:print("Pass1")if mx>386 and mx<428 and my>905 and my<920:print("Pass1")if mx>344 and mx<386 and my>905 and my<920:print("Pass1")if mx>302 and mx<344 and my>905 and my<920:print("Pass")if mx>260 and mx<302 and my>905 and my<920:print("Pass1")if mx>218 and mx<260 and my>905 and my<920:print("Pass1")if mx>176 and mx<218 and my>905 and my<920:print("Pass1")if mx>134 and mx<176 and my>905 and my<920:print("Pass1")Which looks really bad. I'm making a monopoly game and I am adding 2 onscreen buttons foreach property. Meaning that there will be over 100 different sets of (mx,my). It looks very inefficient just based on looking around at other people's code. Since there will be so many different clickable sections of the board I need to find a way to both make it more efficient and easier to read.Although it would be nice for someone to "just do it" I'd much rather have a response with a lot of links. With this method I would need also 100 text_surfaces with different names, 100 different variable n's. My thought process is making something to store all n's, text_surfaces and recalling it. However I don't really know how to do that what to call it and whether or not it "import from" might work.

If this code works, this is rather a question for codereview.stackexchange.com.

**2019年04月25日44分33秒**

Hi Steven, welcome to Stack Overflow! This is a good question and there are certainly things we can show you to improve, but it's in the wrong place. Your code works, you just want to make it better and are looking for people to review it. The place for that is codereview.stackexchange.com . Could you move it there please?

**2019年04月25日44分33秒**

Welcome to stackoverflow! This site is about code which does not work, so if you have a question about coding style, you might want to ask it on codereview

**2019年04月25日44分33秒**

Hint: the my check is always the same, you could do that in one if my ...: at the top and not repeat it every time. For mx, you only seem to want to exclude certain numbers like 806, 764 etc, so you could do if mx not in (806, 764, ...). But overall, there's probably a better algorithm/approach to be found here.

**2019年04月25日44分33秒**

Steven: I disagree with deceze and think it would be OK for you to leave your question posted here. I added a "pygame" tag, because the module may include something to help with a (fairly common) problem like this.

**2019年04月25日44分33秒**

I wanted to simulate the numbers of clicks and I ended up figuring out why the site is called stackoverflow. I forgot to add how many times the loop goes throw so it gave me the error. Essentially I made a function within a function within a function...

**2019年04月25日44分33秒**

- What is a clean, pythonic way to have multiple constructors in Python?
- Why do python lists have pop() but not push()
- Why doesn't list have safe “get” method like dictionary?
- Is a Python list guaranteed to have its elements stay in the order they are inserted in?
- Nested if-statements, clean code, and being Pythonic, with controller/keyboard input
- How to compare the elements of a list to a 2-dimensional list (without using a huge amount of if/elif/else statements)
- I have a single line list and want to covert it to a multi dimensional list
- Loop stopping on third element in list
- I have two lists in a for loop and I want to format the output
- Python cleaning list of strings of lists

ADS