0
How can I shorten this code?
https://code.sololearn.com/cXoFilL4Gs40/?ref=app If you don't understand what is this file all about, read about the game here... https://code.sololearn.com/cVscSJBWNae3/?ref=app
4 ответов
+ 4
Rather than looking for a way to shorten, I recommend improving readability, which would slightly increase the code.
I'd pass all those properties in as an object into their respective constructors and set those values during instantiation.
You can then remove the subsequent calls to set_properties() for each creature.
+ 2
For the amount of content it has, your code is quite short! If you're interested in making clean codes, the only thing I can suggest is to make your lines have no more than 79 characters.
0
If you want to use lambdas, it can greatly shorten your code.
See cepagrave and VcC's tutorial in that case
https://www.sololearn.com/post/44470/?ref=app
edit:
Aditya Rana okay, but now I have to create sequence and not have time for this. will help a couple of hours later if nobody answered this.😊
0
Roneel
I want to shorten the way I am creating creatures and setting their properties (not the functions). It seems redundant and not #Pythonic.