Pythonic one-liner for populating a sequence

Say I want to calculate the first n Fibonacci numbers and put them into a list. With a ‘for’ loop, this is trivial. But is there a one-liner – a kind of list comprehension magic, perhaps – that could achieve this more elegantly?

From a user who feels pretty confident, but is always looking for the most Pythonic approach!

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.