+ 1
How to write one line codes ?
5 Answers
+ 2
You can for example look at the codes of the user CĂ©pagrave [busyCarpenting].
He has written a lot of oneliners for you to study - or be confused about. ;-)
+ 2
You can use lambdas to use their parameters as variables,
ternary operators to test conditions,
and tuples to perform multiple statements in 1 lambda expression.
+ 1
U can use phython for writing one line code, such as printing text on screen and adding operations .
0
Say example
0
Python oneliners are mostly divided into two groups. Ones that use List Comprehensions, and ones that use lambdas. I often use both
Using various formatting methods etc you can reduce a lot of more complex programs into one line, though they are generally difficult to read
List Comprehensions:
https://code.sololearn.com/cTzSv0yN5enw/?ref=app
Lambdas and List comprehensions:
https://code.sololearn.com/cXO9hzZ3Dzay/?ref=app
https://code.sololearn.com/c0n5X8dwOW3D/?ref=app
https://code.sololearn.com/cexP9VPTU0hP/?ref=app
https://code.sololearn.com/chu0Xaheiq4W/?ref=app
https://code.sololearn.com/c1FgMcmsA55i/?ref=app