I'm attending AI Coding Summit with 5k other participants to learn how AI transforms software development and stay up to date with the latest AI tools - get your free remote ticket and join me there!
https://t.co/YBJBB5gzH5
#AICodingSummit
Interesting question and the Ans is - B) 1
The key learning point from this problem is that - Python's `split()` method divides a string into a list of smaller strings based on a specified delimiter, but when called on an empty string it returns a list containing a single empty string.
Lets dive in
-----------
๐ Firstly, let's break down the code snippet `"".split(" ")`. Here, `split()` is a built-in method in Python which is used to split a string into a list where each word is a separate list item. This method takes a delimiter as an argument, which is the character we want to use to split the string. If we don't pass any argument, the default delimiter is a whitespace.
In this particular case, you're calling `split(" ")` on an empty string (`""`). This means you're asking Python to divide the empty string wherever there's a space (" ").
But since there are no characters (including spaces) in the empty string to begin with, there's nowhere to make a division. As a result, Python just returns a list containing the original, undivided string. In this case, the original string was empty, so Python returns a list with a single item: the empty string. So, the return value of `"".split(" ")` is `[""]`.
๐ Now, let's look at the `len()` function. In Python, `len()` is a built-in function that returns the number of items in an object. When a string is passed as an argument to the `len()` function, it returns the number of characters in that string. But when a list is passed, `len()` will return the number of items present in that list.
So, you're passing the list `[""]` (the result of `"".split(" ")`) to the `len()` function. This list only has one item: the empty string.
So, `len([""])` returns `1`, which is the number of items in the list.
------------------
๐ If you enjoyed this explanation:
โ 1. Give me a follow @rohanpaul_ai for more of this every day and
โ 2. Like & Retweet this tweet:
โ 3. Consider subscribing to my MachineLearning YouTube channel -
https://t.co/l5QgUF1Du5
#python #100daysofcode #softwareengineer #programming #coding #java #javascript #programmer #developer #html #coder #code #computerscience #technology #css #pythonprogramming #linux #php #software #reptilesofinstagram #webdevelopment #webdeveloper #tech #codinglife #algorithms #algorithm #datastructures #statistics #programmers #analytics #leetcode #MachineLearning #ArtificialIntelligence #datascience #nlp #reactjs #100daysofmlcode #nlp #textprocessing #programminglife #hacking #learntocode #softwaredeveloper #interview
Chrome has 3.2 billion users.
But most people don't know how to unlock its full potential.
Here are 10 chrome extensions you'll wish you knew sooner (all free):
#Kolkata
Need #Blood Type : Any group, as we need to exchange it from blood bank
At : Medica Hospital, Mukundpur, Kolkata
Blood Component : Blood
Number of Units : 4
Number : 7277452045 / 7986063108
Patient : Shabina Khatoon
Illness : Problem in bone marrow
@BloodDonorsIn
Here are 12 skills that you wanna add to your Data Science / Machine Learning resume.
The first 6 are foundational and important. The other 6 are in crazy high demand, harder to build, and will set you apart.
๐งต๐
Block-sparsity is a smart way to make sparse computations efficient on *any* type of GPU
It's one of the ingredients behind sparse transformers like GPT3
Franรงois has released the 1st version of an efficient block-sparse library for PyTorch & I'm very excited about this project
Here's a talk I gave at https://t.co/DFwf6jghsC on (1) how to convert a neural network into a symbolic equation, and (2) why I think symbolic regression should be a primary ML algorithm in astrophysics. Lots of insightful questions from the audience!
https://t.co/mjHDdntbMg
Exceedingly excellent Ampere GPU commentary, as always from @Tim_Dettmers ๐๐, effectively required reading for deep learning. Explains the present need to pay close attention to memory, size and bandwidth
Found some free time to release a library I've been using for the last year to abstract away some PyTorch boilerplate. It's pretty lean and only meant to make my research projects cleaner and more reproducible.
https://t.co/0PzgZQJh4Q