0

Cleaner Code

TRYING TO MAKE MY CODE LOOK MORE SIMPLER IS THAT ANYWAY TO MAKE THIS CODE BECOME ONE LINE ? https://code.sololearn.com/cMe8FzYrOg81/?ref=app

13th Nov 2020, 1:57 PM
Chase Chai
Chase Chai - avatar
2 odpowiedzi
+ 6
You can use a simple list comprehension, that is made for tasks like this: print([num for num in a if num <=5])
13th Nov 2020, 3:20 PM
Lothar
Lothar - avatar
+ 3
Sometimes shorter is more confusing, making the longer version "cleaner" https://code.sololearn.com/c3Ihd6b9h2ZU/?ref=app
13th Nov 2020, 2:03 PM
Slick
Slick - avatar