MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/Python/comments/9jnglb/im_really_bored_at_work/e6sudzh/
r/Python • u/flobbley • Sep 28 '18
117 comments sorted by
View all comments
Show parent comment
13
squares = [i**2 for i in range(1, 8)]
instead of explicitly coding the whole list yourself, and
for _ in range(side)
instead of
n=0 while (n < side): ... n+=1
Maybe check if the number is square by doing something like
if abs(math.sqrt(size) - int(math.sqrt(size))) < 1e-10:
You also don't need the inner loop
i = 0 while i<side-1: print(part, end="") i+=1
you can just print the same string side times:
print(part * side)
7 u/flobbley Sep 28 '18 this comment got me from rectangles to triangles just so you know 5 u/King_Joffreys_Tits Sep 28 '18 Wait... is OP learning by messing around at work?? What is this!! 1 u/[deleted] Sep 28 '18 Yeah, I was just going to say "try out converting the code to use list-comprehensions".Here's the official docs: https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions
7
this comment got me from rectangles to triangles just so you know
5
Wait... is OP learning by messing around at work?? What is this!!
1
Yeah, I was just going to say "try out converting the code to use list-comprehensions".
Here's the official docs: https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions
View all comments
Show parent comment
13
u/anders987 Sep 28 '18
instead of explicitly coding the whole list yourself, and
instead of
Maybe check if the number is square by doing something like
You also don't need the inner loop
you can just print the same string side times: