Casting in python
Casting is a process of converting a datatype into another. For example, converting string data into an integer data or vise versa.
There are two kinds of casting — Implicit and Explicit.
Implicit — values converted automatically by the interpreter/compiler.
Explicit — values are not automatically converted, we need to manually convert them.
Let’s see what happens we don’t convert our values.
Error occurred because python did not implicitly converted string to integer or vise versa. In such situations we need to manually convert data from one type to the another.
In python we have three functions to convert values from one type to the another.
str(value) — converts value into string.
float(value) — converts value into float.
int(value) — converts value into int.
Please have a look at this short 1-min video to understand how to use this functions.
Thank you and have a nice day :)