Ask coding questions

← Back to all posts
Game In Python
[deleted]

Hello, I'm remaking a game in python and i was wondering if there is a way i could shorten some of my code, here it is:

as you can see it is quite lengthy im really new to python so if this is normal please let me know

Answered by ArchieMaclean [earned 5 cycles]
View Answer
Voters
OathOfCode
OreOlad
Murzikal
YousufRashid
venkatakrishnai
UlrichRivera
Comments
hotnewtop
ArchieMaclean

You could do it with a 2D list, like this:

Please upvote if this helps :)

[deleted]

@ArchieMaclean This way is good thanks

Murzikal

lol stanley parable

Aidan72

@Murzikal Yes i love it, they are remaking it with more content

Murzikal

@Aidan72 lol its a fun game, i think you made a good choice

Lord_Poseidon

Since the timings are irregular and all, you can try putting the text and times in seperate lists and then call them with a loop

[deleted]

@Lord_Poseidon uh can you please elaborate this is literally my first time ever using anything other than the website building languages
(not meant to be passive aggressive)

Lord_Poseidon

@AidanSlyker oh sorry.
Basically, what I mean is put all your text in a list of strings(I hope you know what they are).like

and a list of times like:t=[2,2,4,5,...]
And then use a loop like

upvote if this helps!

[deleted]

@Lord_Poseidon i think i see what you mean, thank you :)

ArchieMaclean

@Lord_Poseidon sorry, I didn't see that you had answered :|

[deleted]

@Lord_Poseidon would i put that all in

nvm, im doing it a different way

ArchieMaclean
Lord_Poseidon

@ArchieMaclean NVM. Your way was better.Why didn't I think of 2d arrays?

RayanshSarda

cool

Aidan72

:facepalm: I HAVE BEEN USING THE WRONG ACCOUNT FOR 2 DAYS STRAIGHT WHAT LMAO

a5rocks

You could make this much more readable.