+ 1

How to write one line codes ?

20th Aug 2019, 4:45 PM
Sai Krishna
Sai Krishna - avatar
6 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. ;-)
20th Aug 2019, 5:03 PM
HonFu
HonFu - avatar
+ 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.
20th Aug 2019, 7:10 PM
Seb TheS
Seb TheS - avatar
+ 1
U can use phython for writing one line code, such as printing text on screen and adding operations .
20th Aug 2019, 5:30 PM
Piyush Srivastava
Piyush Srivastava - avatar
0
Say example
20th Aug 2019, 4:52 PM
Sai Krishna
Sai Krishna - avatar
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
20th Aug 2019, 6:21 PM
Trigger
Trigger - avatar