+ 20
Good Style - bad Style
One Question was to add '3' on the first and the plast position of an integer. My solution is: a = 253 b = len(str(a)) c = 10**(b+1) print (c*3+a*10+3) The same code is possible as an oneliner: print ((3*10**((int(len(str(253)))+1)))+253*10+3) But who can read and understand this? What do you think is the better way to write this code down?
5 Respuestas
+ 7
Oneliners are mostly difficult to understand. In my view, the only advantage of it is when you need to impress someone ;)
+ 14
(i use oneliners on eval/exec)
+ 7
@Sebastian: I don't think so. The decrease/increase in performance depends on the no. of calculations or operations you do in your code. That's what I recall...
+ 3
ofcourse the first one is way better than the second !
+ 2
Thanks. By the way: has the number of lines an effect on the performance of the Code?