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

13th Nov 2018, 7:11 PM
Aditya Rana
4 Réponses
+ 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.
14th Nov 2018, 4:06 AM
David Carroll
David Carroll - avatar
+ 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.
14th Nov 2018, 3:37 AM
Kishalaya Saha
Kishalaya Saha - avatar
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.😊
13th Nov 2018, 7:15 PM
Roneel
Roneel - avatar
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.
13th Nov 2018, 7:19 PM
Aditya Rana