All Go Rust Python PHP JavaScript
Chrome Dev Summit to secure your spot in workshops, office hours and learning lounges!

How to Remove all Empty Strings from a List of Strings in Python

In Python, there are 3 ways to remove all empty strings from a list of strings. Using filter Function The filter(function, iterable) function constructs an iterator from those elements of iterable for which function returns true. The following exam...
Sambhav Khandelwal

How to Concatenate a List of Strings into a Single String in Python

In Python, using the str.join function is the easiest way to concatenate a list of strings into a single string Using str.join Function The str.join() method returns a string which is the concatenation of the strings in iterable. A TypeError will be...
aweis

How to Return Dictionary Keys as a List in Python

In Python, there are 3 ways to return dictionary keys as a list. Using keys Function The dict.keys() function returns a view object that displays a list of all the keys in the dictionary in order of insertion. See the following example: #!/usr/...
Sambhav Khandelwal

How to Determine if an Object is Iterable in Python

In Python, there are 2 ways to determine if an object is iterable. Using Duck Typing Duck typing is a concept related to dynamic typing, where the type or the class of an object is less important than the methods it defines. When you use duck typing...
Unused

How to Remove Duplicates in List in Python

In Python, there are 3 ways to remove duplicates in list. Using Built-in set Function The built-in set() function returns a new set object, optionally with elements taken from iterable. If you later need a real list again, you can similarly pass the...
pooriabt

How to Convert Vec to a String in Rust

In Rust, there are 2 ways to convert Vec to a string. Using collect Function The collect() function transforms an iterator into a collection. collect() can take anything iterable, and turn it into a relevant collection. This is one of the more powe...
Patcher56

How to Know If an Object has an Attribute in Python

In Python, there are 4 ways to know if an object has an attribute. Using hasattr Method The arguments are an object and a string. The result is True if the string is the name of one of the object’s attributes, False if not. For example, #!/usr/...
ada