57
Awesome Team
Vedran Čačić
https://web.math.hr/~veky
Last seen 14 hours ago
Member for 11 years, 6 months, 6 days
Difficulty Advanced
We shall not cease from exploration, and the end of all our exploring will be to arrive where we started and know the place for the first time.
Lines 12-14 can be simply written as
f = kwargs.get('key', lambda x: x)
Also, None can be aliased. :-)
val = fval = None
More
"return None" is the same as "don't return anything". You don't need lines 5 and 12.
More
aargh. My eyes hurt. What good can you _possibly_ think will come out of a line as
if b != int and b != str and b != list and b != float and b !=bool:
And lines 5-11 are really mind-bending. Is this some kind of bet? How to convert iterable to list in the most complicated way imaginabl
More
Lines 2-4: you can set
a = b = c = 0
And in line 15, you can just say
return a and b and c and len(data) >= 10
More
c.extend([x]) is much clearer as c.append(x). And whole business is just a list comprehension, but you don't need to know about that yet. :-)
More
First, why a special case that is not special at all (lines 2-4)??
Second, why are you str-ifying i and j?
More
sequences are boolable. You can just write "if not args" in line 2 (or even "if args" if you switch lines 3 and 5).
More
That "sum" being red wasn't enough of a hint for you? :-)
Yes, there is a sum builtin. It might come handy. ;-)
Also, you might learn about slices and negative indices.
More
Again, you might see (and exploit) a pattern in the above code. At least in lines 10-17. :-)
More
You see what happens when you don't exploit patterns? Your code explodes. :-P
More
Argh. Those explicit slices are really unpythonic. Please use split.
Also, see dict.setdefault. ;-)
More
int(a/b) is a//b. Also, you don't have to round the result: "four digits precision" here means "(at least) four correct digits", which you can see from "±0.0001".
More
You could append fresh [] to result between lines 4 and 5. (Then it would be obvious that it's just a list comprehension.:) But this way is also ok.
range(0,bla) is just range(bla).
loop in line 5 can be more pythonic:
for row in data:
result[i].append(row[i])
More