Here is a maze game from my friend... We need optimisation

We need optimisation… You know 1300 lines of code ain’t a short program(neither the best).
I know that we put in str(input()). That is because we did a bit of C++ 2 years before Python, and you had to define the data type, and we just found out that input() so we went ahead to find the syntax of if-statement and made it… He did most(about all) of the code cuz I was on a vacation so all credits go to him.(credits- Sankalp Srivastava)

[Zed: drive link removed]

We are very thankful for any help. It would be really generous if @zedshaw helps
(I will give like to any help instead of replying to not make the thread too long)

Hello @Dynamo_Nishant.

I saw one thing that perhaps can be changed a little.

start = str(input("  \n Type sum to start:  "))
while start != 'Eldar' and start != 'eldar' and start != 'EldarHarlaquin' and start != 'eldarharlaquin' and start != 'Eldarharlaquin':

If you put in

start = start.lower()

It could be shortened to:

start = str(input("  \n Type sum to start:  "))
start = start.lower()
while start != 'eldar' and start != 'eldarharlaquin':

You have a variable called ”key” where following code could be shortened in similar way I think.

I hope that is helpful.


Hi @Dynamo_Nishant, Google Drive links aren’t safe due to the weird way that google tries to use them to suck up people’s personal information.

Could you please create an account on and put your code in there. Bonus feature to this is then I can go in and actually send you changes to improve your code.


1 Like

Here as you said, this is the original file, I am not too familiar with GitHub so there might be some errors, DM me if there are.

Also, I too am working on my own, I am stuck at a point which I have marked in the comments. Here’s my version, it’s still incomplete read comments to find where I am stuck. It would be better if you help me with mine instead of debugging as it will take a lot of time
Also thanks a lot :heart::heart::heart::love_you_gesture:

1 Like

Sweet! That’s looking good. You should keep working on this and see how far you can get. One thing I can say is, start with a smaller version of what you want, get that working, then build on that.

1 Like

Dear @zedshaw I think you were in a rush and missed what i wanted help with… There are comments which mark where I am facing a problem, please read them, they are nice and easy to see. There is a local variable that I want to use in another function, I can’t explain without the source code so please visit my repository and read, there is a big comment like a tape which separates the parts i need help with and then there is a comment explaining what is wrong. Any help even a slightest hint will be helpful. BTW I updated it a bit, now you can at least play it. Also you can type developer at the menu to skip all the BS(no don’t say it with that name, its my creativity) and directly reach the maze.

(P.S. I know the return method to get variables out of functions, but the problem is that I dont want the function to run twice as it prints stuff and asks the player. Maybe I don’t have the entire info on how to use return to make variables global as I am still at exercise 33 in lp3thw and I like to give myself a challenge to use the most limited resources.)

No, I read it, I just wanted you to keep trying.

So you mean this line:

You can link directly to lines in your code by clicking the line number on the left. That makes it easier to show people where you need help.

If you want int_a available everywhere then you need to:

  1. Put it at the top of your script and give it a value.

    int_a = 0

  2. In every function that uses it put global int_a.

  3. Alternatively, create a object or dict that has this information in it, then pass to every function.

  4. If you do the globals, you should capitalize the variable and give it some useful name like GAME_STATE or something that’s not INT_A. Capitals are just a standard among programmers that says the variable is probably a global or a constant.

1 Like