Python built-ins worth learning
Python refuses to coerce that integer to a string, so we need to manually do it ourselves, using the built-in function (class technically, but as I said, I’ll be calling these all functions):
Do you have user input and need to convert it to a number? It takes an iterable of hashable values (strings, numbers, or other immutable types) and returns a :
There’s no way to make an empty set with the set literal syntax (plain makes a dictionary), so the function is the only way to make an empty set:
Actually that’s a lie because we have this:
But that syntax is confusing (it relies on a lesser-used feature of the operator), so I don’t recommend it. You’ll pretty much see used exclusively in the part of a loop:
There are some other ways to reverse Python lists besides the function:
But the function is usually the best way to reverse any iterable in Python.
Source: treyhunner.com