Merges two or more lists into a list of lists, combining elements from each of the input lists based on their positions.
.👉🏻Use max() combined with a list comprehension to get the length of the longest list in the arguments.
.👉🏻Use range() in combination with the max_length variable to loop as many times as there are elements in the longest list.
.👉🏻If a list is shorter than max_length, use fill_value for the remaining items (defaults to None).
.👉🏻zip() and itertools.zip_longest() provide similar functionality to this snippet.
Code:
def merge(*args, fill_value = None): max_length = max([len(lst) for lst in args]) result = [] for i in range(max_length): result.append([ args[k][i] if i < len(args[k]) else fill_value for k in range(len(args)) ]) return result
Merges two or more lists into a list of lists, combining elements from each of the input lists based on their positions.
.👉🏻Use max() combined with a list comprehension to get the length of the longest list in the arguments.
.👉🏻Use range() in combination with the max_length variable to loop as many times as there are elements in the longest list.
.👉🏻If a list is shorter than max_length, use fill_value for the remaining items (defaults to None).
.👉🏻zip() and itertools.zip_longest() provide similar functionality to this snippet.
Code:
def merge(*args, fill_value = None): max_length = max([len(lst) for lst in args]) result = [] for i in range(max_length): result.append([ args[k][i] if i < len(args[k]) else fill_value for k in range(len(args)) ]) return result
Secure video calling is in high demand. As an alternative to Zoom, many people are using end-to-end encrypted apps such as WhatsApp, FaceTime or Signal to speak to friends and family face-to-face since coronavirus lockdowns started to take place across the world. There’s another option—secure communications app Telegram just added video calling to its feature set, available on both iOS and Android. The new feature is also super secure—like Signal and WhatsApp and unlike Zoom (yet), video calls will be end-to-end encrypted.
How to Invest in Bitcoin?
Like a stock, you can buy and hold Bitcoin as an investment. You can even now do so in special retirement accounts called Bitcoin IRAs. No matter where you choose to hold your Bitcoin, people’s philosophies on how to invest it vary: Some buy and hold long term, some buy and aim to sell after a price rally, and others bet on its price decreasing. Bitcoin’s price over time has experienced big price swings, going as low as $5,165 and as high as $28,990 in 2020 alone. “I think in some places, people might be using Bitcoin to pay for things, but the truth is that it’s an asset that looks like it’s going to be increasing in value relatively quickly for some time,” Marquez says. “So why would you sell something that’s going to be worth so much more next year than it is today? The majority of people that hold it are long-term investors.”