One liner codes

Good day to all of you that can read this!

I am a beginner at Python and currently studying all the fundamentals about it. I came across at some websites particularly, Hackerrank and HackerEarth, almost all of their solutions at the sample problems are one-liner codes. I just want to ask if one-liners are a thing when it comes to professional programming or is it just for competitions. Thank you! I hope you are all doing well!

That depends… Both sites seem to require an account so I couldn’t look at any examples.

Generally, professional code needs to be maintainable. That implies readability and understandability of the code. Short code can be beautiful, clear, readable and understandable while one-liners written just to fit the logic into a single line can be so cryptic that even the author doesn’t understand them anymore a few weeks after writing them.

Simply use your good judgement and don’t copy&paste code you don’t understand.

Thank you so much! I have been able to perform some practice problems on my own using short codes, but when I saw their one-liners I suddenly questioned my efficiency in writing codes. Thank you for enlightening me!